コード例 #1
0
    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
コード例 #2
0
ファイル: test_tasks.py プロジェクト: eliesmr4/myedx
    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
コード例 #3
0
ファイル: test_tasks.py プロジェクト: zhenzhai/edx-platform
    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
コード例 #4
0
    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
コード例 #5
0
    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
コード例 #6
0
ファイル: test_tasks.py プロジェクト: Akif-Vohra/edx-platform
    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
コード例 #7
0
ファイル: test_tasks.py プロジェクト: weicliu/edx-platform
    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