예제 #1
0
    def setUp(self):
        self.client = API()
        self.mock_project_data = [{
            "announcement":
            "..",
            "completed_on":
            None,
            "id":
            1,
            "is_completed":
            False,
            "name":
            "Project1",
            "show_announcement":
            True,
            "url":
            "http://<server>/index.php?/projects/overview/1"
        }, {
            "announcement":
            "..",
            "completed_on":
            False,
            "id":
            2,
            "is_completed":
            True,
            "name":
            "Project2",
            "show_announcement":
            True,
            "url":
            "http://<server>/index.php?/projects/overview/2"
        }]

        self.projects = copy.deepcopy(self.mock_project_data)
예제 #2
0
 def test_no_env(self):
     client = API()
     config = client._conf()
     self.assertEqual(config['email'], '*****@*****.**')
     self.assertEqual(config['key'], 'your_api_key')
     self.assertEqual(config['url'], 'https://<server>')
     self.assertEqual(client.verify_ssl, True)
예제 #3
0
 def test_user_env(self):
     email = '*****@*****.**'
     os.environ['TESTRAIL_USER_EMAIL'] = email
     client = API()
     config = client._conf()
     self.assertEqual(config['email'], email)
     self.assertEqual(config['key'], 'your_api_key')
     self.assertEqual(config['url'], 'https://<server>')
예제 #4
0
 def test_key_env(self):
     key = 'itgiwiht84inf92GWT'
     os.environ['TESTRAIL_USER_KEY'] = key
     client = API()
     config = client._conf()
     self.assertEqual(config['email'], '*****@*****.**')
     self.assertEqual(config['key'], key)
     self.assertEqual(config['url'], 'https://<server>')
예제 #5
0
 def test_url_env(self):
     url = 'https://example.com'
     os.environ['TESTRAIL_URL'] = url
     client = API()
     config = client._conf()
     self.assertEqual(config['email'], '*****@*****.**')
     self.assertEqual(config['key'], 'your_api_key')
     self.assertEqual(config['url'], url)
예제 #6
0
 def test_config_no_url(self):
     os.remove(self.config_path)
     shutil.copyfile('%s/testrail.conf-nourl' % self.test_dir,
                     self.config_path)
     with self.assertRaises(TestRailError) as e:
         API()
     self.assertEqual(str(e.exception),
                      ('A URL must be set in environment ' +
                       'variable TESTRAIL_URL or in ~/.testrail.conf'))
예제 #7
0
 def test_config_no_key(self):
     os.remove(self.config_path)
     shutil.copyfile('%s/testrail.conf-nokey' % self.test_dir,
                     self.config_path)
     with self.assertRaises(TestRailError) as e:
         API()
     self.assertEqual(str(e.exception),
                      ('A password or API key must be set in environment ' +
                       'variable TESTRAIL_USER_KEY or in ~/.testrail.conf'))
예제 #8
0
    def setUp(self):
        self.client = API()
        self.client.set_project_id(1)
        self.mock_suites_data_1 = [{
            "description":
            "..",
            "id":
            1,
            "name":
            "Setup & Installation",
            "project_id":
            1,
            "url":
            "http://<server>/index.php?/suites/view/1"
        }, {
            "description":
            "..",
            "id":
            2,
            "name":
            "Setup & Installation",
            "project_id":
            1,
            "url":
            "http://<server>/index.php?/suites/view/2"
        }]
        self.mock_suites_data_2 = [{
            "description":
            "..",
            "id":
            3,
            "name":
            "Setup & Installation",
            "project_id":
            2,
            "url":
            "http://<server>/index.php?/suites/view/1"
        }, {
            "description":
            "..",
            "id":
            4,
            "name":
            "Setup & Installation",
            "project_id":
            2,
            "url":
            "http://<server>/index.php?/suites/view/2"
        }]

        self.suites_1 = copy.deepcopy(self.mock_suites_data_1)
        self.suites_2 = copy.deepcopy(self.mock_suites_data_2)
예제 #9
0
 def __init__(self,
              project_id=0,
              email=None,
              key=None,
              url=None,
              verify_ssl=True,
              proxies=None):
     self.api = API(email=email,
                    key=key,
                    url=url,
                    verify_ssl=verify_ssl,
                    proxies=proxies)
     self.api.set_project_id(project_id)
     self._project_id = project_id
예제 #10
0
 def test_no_config_file(self):
     os.remove(self.config_path)
     key = 'itgiwiht84inf92GWT'
     email = '*****@*****.**'
     url = 'https://example.com'
     os.environ['TESTRAIL_URL'] = url
     os.environ['TESTRAIL_USER_KEY'] = key
     os.environ['TESTRAIL_USER_EMAIL'] = email
     client = API()
     config = client._conf()
     self.assertEqual(config['url'], url)
     self.assertEqual(config['key'], key)
     self.assertEqual(config['email'], email)
     self.assertEqual(client.verify_ssl, True)
예제 #11
0
    def setUp(self):
        self.client = API()
        self.mock_user_data = [{
            "email": "*****@*****.**",
            "id": 1,
            "is_active": 'true',
            "name": "Han Solo"
        }, {
            "email": "*****@*****.**",
            "id": 2,
            "is_active": 'true',
            "name": "Jabba the Hutt"
        }]

        self.users = copy.deepcopy(self.mock_user_data)
예제 #12
0
 def test_get_users_cache_timeout(self, mock_get):
     self.client = API()
     mock_response = mock.Mock()
     expected_response = self.users
     url = 'https://<server>/index.php?/api/v2/get_users'
     mock_response.json.return_value = self.mock_user_data
     mock_response.status_code = 200
     mock_get.return_value = mock_response
     actual_response = self.client.users()
     timeout = self.client._timeout
     self.client._users['ts'] = datetime.now() - timedelta(seconds=timeout)
     actual_response = self.client.users()  # verity cache timed out
     c = mock.call(url,
                   headers={'Content-Type': 'application/json'},
                   params=None,
                   verify=True,
                   auth=('*****@*****.**', 'your_api_key'))
     mock_get.assert_has_calls([c, mock.call().json()] * 2)
     self.assertEqual(2, mock_response.json.call_count)
     self.assertEqual(expected_response, actual_response)
예제 #13
0
 def __init__(self, project_id=0, email=None, key=None, url=None):
     self.api = API(email=email, key=key, url=url)
     self.api.set_project_id(project_id)
     self._project_id = project_id
예제 #14
0
 def __init__(self, content=None):
     self._content = content or dict()
     self.api = API()
     self._custom_methods = custom_methods(self._content)
예제 #15
0
 def __init__(self, content):
     self._content = content
     self._api = API()
예제 #16
0
 def test_ssl_env(self):
     os.environ['TESTRAIL_VERIFY_SSL'] = 'False'
     client = API()
     self.assertEqual(client.verify_ssl, False)
예제 #17
0
 def test_config_verify_ssl_false(self):
     os.remove(self.config_path)
     shutil.copyfile('%s/testrail.conf-nosslcert' % self.test_dir,
                     self.config_path)
     client = API()
     self.assertEqual(client.verify_ssl, False)
예제 #18
0
    def setUp(self):
        self.client = API()
        self.client.set_project_id(1)
        self.mock_plans_data_1 = [{
            "id": 1,
            "name": "Test Plan #1",
            "is_completed": False,
            "description": "..",
            "project_id": 1,
            "milestone_id": 1,
            "url": "http://<server>/index.php?/plans/view/1",
            "assignedto_id": None,
            "blocked_count": 1,
            "completed_on": None,
            "created_by": 1,
            "created_on": 1393845644,
            "untested_count": 6,
            "passed_count": 5,
            "failed_count": 2,
            "entries": []
        }, {
            "id": 2,
            "name": "Test Plan #2",
            "is_completed": False,
            "description": "..",
            "project_id": 1,
            "milestone_id": 2,
            "url": "http://<server>/index.php?/plans/view/2",
            "assignedto_id": None,
            "blocked_count": 1,
            "completed_on": None,
            "created_by": 1,
            "created_on": 1393845644,
            "untested_count": 6,
            "passed_count": 5,
            "failed_count": 2,
            "entries": []
        }]
        self.mock_plans_data_2 = [{
            "id": 3,
            "name": "Test Plan #3",
            "is_completed": False,
            "description": "..",
            "project_id": 2,
            "milestone_id": 3,
            "url": "http://<server>/index.php?/plans/view/3",
            "assignedto_id": 1,
            "blocked_count": 2,
            "completed_on": None,
            "created_by": 2,
            "created_on": 1393843644,
            "untested_count": 6,
            "passed_count": 5,
            "failed_count": 2,
            "entries": []
        }, {
            "id": 4,
            "name": "Test Plan #4",
            "is_completed": False,
            "description": "..",
            "project_id": 2,
            "milestone_id": 3,
            "url": "http://<server>/index.php?/plans/view/4",
            "assignedto_id": 1,
            "blocked_count": 2,
            "completed_on": None,
            "created_by": 2,
            "created_on": 1393843644,
            "untested_count": 6,
            "passed_count": 5,
            "failed_count": 2,
            "entries": []
        }]

        self.plans_1 = copy.deepcopy(self.mock_plans_data_1)
        self.plans_2 = copy.deepcopy(self.mock_plans_data_2)
예제 #19
0
 def setUp(self):
     self.client = API()
예제 #20
0
 def __init__(self, content=None):
     self._content = content or dict()
     self.api = API()