def test_get_api_client(self, mock_build_token): """ Ensure the function is making the right API calls based on inputs """ student = UserFactory() ClientFactory.create(name='credentials') api_config = self.create_credentials_config() mock_build_token.return_value = 'test-token' api_client = tasks.get_api_client(api_config, student) expected = CREDENTIALS_INTERNAL_SERVICE_URL.strip('/') + '/api/v2/' self.assertEqual(api_client._store['base_url'], expected) # pylint: disable=protected-access self.assertEqual(api_client._store['session'].auth.token, 'test-token') # pylint: disable=protected-access
def test_get_api_client(self, mock_get_id_token): """ Ensure the function is making the right API calls based on inputs """ student = UserFactory() ClientFactory.create(name="programs") api_config = self.create_programs_config(internal_service_url="http://foo", api_version_number=99) mock_get_id_token.return_value = "test-token" api_client = tasks.get_api_client(api_config, student) self.assertEqual(mock_get_id_token.call_args[0], (student, "programs")) self.assertEqual(api_client._store["base_url"], "http://foo/api/v99/") # pylint: disable=protected-access self.assertEqual(api_client._store["session"].auth.token, "test-token") # pylint: disable=protected-access
def test_get_api_client(self, mock_build_token): """ Ensure the function is making the right API calls based on inputs """ student = UserFactory() ClientFactory.create(name='credentials') api_config = self.create_credentials_config( internal_service_url='http://foo') mock_build_token.return_value = 'test-token' api_client = tasks.get_api_client(api_config, student) self.assertEqual(api_client._store['base_url'], 'http://foo/api/v2/') # pylint: disable=protected-access self.assertEqual(api_client._store['session'].auth.token, 'test-token') # pylint: disable=protected-access
def test_get_api_client(self, mock_build_token): """ Ensure the function is making the right API calls based on inputs """ student = UserFactory() ClientFactory.create(name='credentials') api_config = self.create_credentials_config( internal_service_url='http://foo' ) mock_build_token.return_value = 'test-token' api_client = tasks.get_api_client(api_config, student) self.assertEqual(api_client._store['base_url'], 'http://foo/api/v2/') # pylint: disable=protected-access self.assertEqual(api_client._store['session'].auth.token, 'test-token') # pylint: disable=protected-access
def test_get_api_client(self, mock_get_id_token): """ Ensure the function is making the right API calls based on inputs """ student = UserFactory() ClientFactory.create(name='programs') api_config = self.create_programs_config( internal_service_url='http://foo', api_version_number=99, ) mock_get_id_token.return_value = 'test-token' api_client = tasks.get_api_client(api_config, student) self.assertEqual(mock_get_id_token.call_args[0], (student, 'programs')) self.assertEqual(api_client._store['base_url'], 'http://foo/api/v99/') # pylint: disable=protected-access self.assertEqual(api_client._store['session'].auth.token, 'test-token') # pylint: disable=protected-access