]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
test_suite: add new ceph_sha1 param, tests for same 863/head
authorDan Mick <dan.mick@redhat.com>
Mon, 23 May 2016 22:56:05 +0000 (15:56 -0700)
committerDan Mick <dan.mick@redhat.com>
Tue, 24 May 2016 16:59:56 +0000 (09:59 -0700)
Signed-off-by: Dan Mick <dan.mick@redhat.com>
teuthology/test/test_suite.py

index ec363bdce8b2c5dfa6044ce9e20d2309d1c4aa82..9c320800ad1338cfd64689454b7ab397f0c7158f 100644 (file)
@@ -12,6 +12,7 @@ import os
 import pytest
 import tempfile
 import random
+import requests     # to mock a Response
 
 @pytest.fixture
 def git_repository(request):
@@ -259,10 +260,60 @@ class TestFlavor(object):
         m_git_branch_exists.return_value = True
         with pytest.raises(suite.ScheduleFailError):
             suite.create_initial_config(
-                'suite', 'suite_branch', 'ceph_hash', 'teuth_branch',
-                None, 'kernel_flavor', 'ubuntu', 'machine_type',
+                'suite', 'suite_branch', 'ceph_hash', None,
+                'teuth_branch', None, 'kernel_flavor', 'ubuntu',
+                'machine_type',
             )
 
+    @patch('requests.head')
+    @patch('teuthology.suite.git_branch_exists')
+    @patch('teuthology.suite.package_version_for_hash')
+    @patch('teuthology.suite.git_ls_remote')
+    def test_sha1_exists(
+        self,
+        m_git_ls_remote,
+        m_package_version_for_hash,
+        m_git_branch_exists,
+        m_requests_head,
+    ):
+        config.gitbuilder_host = 'example.com'
+        m_package_version_for_hash.return_value = 'ceph_hash'
+        m_git_branch_exists.return_value = True
+        resp = requests.Response()
+        resp.reason = 'OK'
+        resp.status_code = 200
+        m_requests_head.return_value = resp
+        # only one call to git_ls_remote in this case
+        m_git_ls_remote.return_value = "suite_branch"
+        result = suite.create_initial_config(
+            'suite', 'suite_branch', 'ceph_branch', 'ceph_hash',
+            'teuth_branch', None, 'kernel_flavor', 'ubuntu', 'machine_type',
+        )
+        assert result.sha1 == 'ceph_hash'
+        assert result.branch == 'ceph_branch'
+
+    @patch('requests.head')
+    @patch('teuthology.suite.git_branch_exists')
+    @patch('teuthology.suite.package_version_for_hash')
+    def test_sha1_nonexistent(
+        self,
+        m_package_version_for_hash,
+        m_git_branch_exists,
+        m_requests_head,
+    ):
+        config.gitbuilder_host = 'example.com'
+        m_package_version_for_hash.return_value = 'ceph_hash'
+        m_git_branch_exists.return_value = True
+        resp = requests.Response()
+        resp.reason = 'Not Found'
+        resp.status_code = 404
+        m_requests_head.return_value = resp
+        with pytest.raises(suite.ScheduleFailError):
+            suite.create_initial_config(
+                'suite', 'suite_branch', 'ceph_branch', 'ceph_hash_dne',
+                'teuth_branch', None, 'kernel_flavor', 'ubuntu',
+                'machine_type',
+            )
 
 class TestMissingPackages(object):
     """