def test_api_url_returns_url_without_trailing_slash_if_present(self): service = Service( api_key='API-KEY', api_url='https://retdec.com/service/api/' ) self.assertEqual(service.api_url, 'https://retdec.com/service/api')
def test_api_url_returns_url_from_environment_if_available(self): try: os.environ['RETDEC_API_URL'] = 'API-URL' service = Service(api_key='API-KEY') self.assertEqual(service.api_url, 'API-URL') finally: # Restore the original state. del os.environ['RETDEC_API_URL']
def test_api_url_returns_given_url_if_explicitly_given(self): service = Service(api_key='API-KEY', api_url='API-URL') self.assertEqual(service.api_url, 'API-URL')
def test_api_url_returns_default_url_when_no_url_was_given(self): service = Service(api_key='API-KEY') self.assertEqual(service.api_url, 'https://retdec.com/service/api')
def test_api_key_returns_given_key_if_explicitly_given(self): service = Service(api_key='API-KEY') self.assertEqual(service.api_key, 'API-KEY')
def test_raises_exception_if_api_key_is_not_given_or_available(self): with self.assertRaises(MissingAPIKeyError): Service()