Beispiel #1
0
 def test_key_on_custom_env_var(self):
     var = 'MY_CUSTOM_CHUK_ENV_VAR'
     os.environ[var] = 'customtest'
     self.assertRaises(ValueError, CompanyHouseAPI)
     api = CompanyHouseAPI(key_environment_var=var)
     self.assertEqual(api._key, 'customtest')
     self.unset_var(var)
Beispiel #2
0
    def test_custom_serializer_assigned(self):
        class MockSerializer:
            pass

        api = CompanyHouseAPI(key='test', serializer=MockSerializer())
        self.assertIsInstance(api._serializer, MockSerializer)
Beispiel #3
0
    def test_custom_client_assigned(self):
        class MockClient:
            pass

        api = CompanyHouseAPI(key='test', client=MockClient())
        self.assertIsInstance(api._client, MockClient)
Beispiel #4
0
 def test_default_client_assigned(self):
     api = CompanyHouseAPI(key='test')
     self.assertIs(api._client, Client)
Beispiel #5
0
 def test_custom_url(self):
     api = CompanyHouseAPI(key='test', url='http://myproxy')
     self.assertEqual(api._key, 'test')
     self.assertEqual(api._url, 'http://myproxy')
Beispiel #6
0
 def test_normal_key(self):
     api = CompanyHouseAPI(key='123')
     self.assertEqual(api._key, '123')
Beispiel #7
0
 def test_key_on_env_var(self):
     os.environ['COMPANY_HOUSE_API_KEY'] = 'test'
     api = CompanyHouseAPI()
     self.assertEqual(api._key, 'test')
     self.unset_var('COMPANY_HOUSE_API_KEY')