Пример #1
0
    def test_get_program_api_data(self):
        """ Verify the method returns data from the Catalog API. """
        program_certificate = ProgramCertificateFactory(site=self.site)
        program_uuid = program_certificate.program_uuid.hex

        program_endpoint = 'programs/{uuid}/'.format(uuid=program_uuid)
        body = {
            'uuid':
            program_uuid,
            'title':
            'A Fake Program',
            'type':
            'fake',
            'authoring_organizations': [{
                'uuid':
                uuid.uuid4().hex,
                'key':
                'FakeX',
                'name':
                'Fake University',
                'logo_image_url':
                'https://static.fake.edu/logo.png',
            }],
            'courses': []
        }

        self.mock_access_token_response()
        self.mock_catalog_api_response(program_endpoint, body)

        self.assertEqual(program_certificate.get_program_api_data(), body)

        # Verify the data is cached
        responses.reset()
        self.assertEqual(program_certificate.get_program_api_data(), body)
Пример #2
0
    def test_get_program_api_data(self):
        """ Verify the method returns data from the Catalog API. """
        program_certificate = ProgramCertificateFactory(site=self.site)
        expected = {"uuid": program_certificate.program_uuid.hex}

        with mock.patch.object(SiteConfiguration, "get_program", return_value=expected) as mock_method:
            self.assertEqual(program_certificate.get_program_api_data(), expected)
            mock_method.assert_called_with(program_certificate.program_uuid)