def test_basic_params_should_return_auth_heaers(self):
        artifactory_api_request = artifactory_system_configuration.ArtifactoryApiRequest(
            self.DOMAIN, self.USERNAME, self.PASSWORD)
        params = artifactory_api_request.basic_params()

        assert 'auth' in params
        assert params['auth'] == requests.auth.HTTPBasicAuth(
            self.USERNAME, self.PASSWORD)
 def test_get_entity(self):
     response_json = {'key': 'value'}
     with requests_mock.Mocker() as request_mock:
         request_mock.register_uri('GET',
                                   "http://domain/path",
                                   json=response_json,
                                   status_code=200)
         artifactory_api_request = artifactory_system_configuration.ArtifactoryApiRequest(
             self.DOMAIN, self.USERNAME, self.PASSWORD)
         get_result = artifactory_api_request.get_entity()
         assert get_result.status_code == 200
         assert get_result.json() == response_json
 def test_patch_entity(self):
     data = {'data-key': 'data-value'}
     request_headers = {'Content-Type': 'application/yaml'}
     response_json = {'key': 'value'}
     with requests_mock.Mocker() as request_mock:
         request_mock.register_uri('PATCH',
                                   "http://domain/path",
                                   request_headers=request_headers,
                                   json=response_json,
                                   status_code=200)
         artifactory_api_request = artifactory_system_configuration.ArtifactoryApiRequest(
             self.DOMAIN, self.USERNAME, self.PASSWORD)
         put_result = artifactory_api_request.patch_entity(data)
         assert put_result.status_code == 200
         assert put_result.json() == response_json
 def test_url_should_return_url_with_fixed_double_slash_in_path(self):
     assert artifactory_system_configuration.ArtifactoryApiRequest(self.DOMAIN, self.USERNAME, self.PASSWORD).url() \
            == "http://localhost:8082/artifactory/api/system/configuration"
     assert artifactory_system_configuration.ArtifactoryApiRequest(self.DOMAIN + '/', self.USERNAME,
                                                                   self.PASSWORD).url() \
            == "http://localhost:8082/artifactory/api/system/configuration"
 def test_url_should_return_url_with_path(self):
     artifactory_api_request = artifactory_system_configuration.ArtifactoryApiRequest(
         self.DOMAIN, self.USERNAME, self.PASSWORD)
     assert artifactory_api_request.url(
     ) == "http://localhost:8082/artifactory/api/system/configuration"