Example #1
0
    def test_award_program_certificate(self):
        """
        Ensure the correct API call gets made
        """
        test_username = '******'
        test_client = EdxRestApiClient('http://test-server', jwt='test-token')

        httpretty.register_uri(
            httpretty.POST,
            'http://test-server/credentials/',
        )

        tasks.award_program_certificate(test_client, test_username, 123,
                                        datetime(2010, 5, 30))

        expected_body = {
            'username':
            test_username,
            'credential': {
                'program_uuid': 123,
                'type': tasks.PROGRAM_CERTIFICATE,
            },
            'attributes': [{
                'name': 'visible_date',
                'value': '2010-05-30T00:00:00Z',
            }]
        }
        last_request_body = httpretty.last_request().body.decode('utf-8')
        self.assertEqual(json.loads(last_request_body), expected_body)
Example #2
0
    def test_award_program_certificate(self):
        """
        Ensure the correct API call gets made
        """
        test_username = '******'
        test_client = EdxRestApiClient('http://test-server', jwt='test-token')

        httpretty.register_uri(
            httpretty.POST,
            'http://test-server/credentials/',
        )

        tasks.award_program_certificate(test_client, test_username, 123, datetime(2010, 5, 30))

        expected_body = {
            'username': test_username,
            'credential': {
                'program_uuid': 123,
                'type': tasks.PROGRAM_CERTIFICATE,
            },
            'attributes': [
                {
                    'name': 'visible_date',
                    'value': '2010-05-30T00:00:00Z',
                }
            ]
        }
        self.assertEqual(json.loads(httpretty.last_request().body), expected_body)
Example #3
0
 def test_award_program_certificate(self):
     """
     Ensure the correct API call gets made
     """
     test_username = '******'
     test_client = EdxRestApiClient('http://test-server', jwt='test-token')
     httpretty.register_uri(
         httpretty.POST,
         'http://test-server/user_credentials/',
     )
     tasks.award_program_certificate(test_client, test_username, 123)
     self.assertEqual(httpretty.last_request().body, json.dumps({'program_id': 123, 'username': test_username}))
Example #4
0
    def test_award_program_certificate(self):
        """
        Ensure the correct API call gets made
        """
        test_username = "******"
        test_client = EdxRestApiClient("http://test-server", jwt="test-token")

        httpretty.register_uri(httpretty.POST, "http://test-server/user_credentials/")

        tasks.award_program_certificate(test_client, test_username, 123)

        expected_body = {"username": test_username, "credential": {"program_id": 123}, "attributes": []}
        self.assertEqual(json.loads(httpretty.last_request().body), expected_body)
Example #5
0
    def test_award_program_certificate(self):
        """
        Ensure the correct API call gets made
        """
        test_username = '******'
        test_client = EdxRestApiClient('http://test-server', jwt='test-token')

        httpretty.register_uri(
            httpretty.POST,
            'http://test-server/user_credentials/',
        )

        tasks.award_program_certificate(test_client, test_username, 123)

        expected_body = {
            'username': test_username,
            'credential': {'program_id': 123},
            'attributes': []
        }
        self.assertEqual(json.loads(httpretty.last_request().body), expected_body)
Example #6
0
    def test_award_program_certificate(self):
        """
        Ensure the correct API call gets made
        """
        test_username = '******'
        test_client = EdxRestApiClient('http://test-server', jwt='test-token')

        httpretty.register_uri(
            httpretty.POST,
            'http://test-server/credentials/',
        )

        tasks.award_program_certificate(test_client, test_username, 123)

        expected_body = {
            'username': test_username,
            'credential': {'program_uuid': 123},
            'attributes': []
        }
        self.assertEqual(json.loads(httpretty.last_request().body), expected_body)