コード例 #1
0
ファイル: test_tasks.py プロジェクト: sshyran/edx-platform
    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')
        assert json.loads(last_request_body) == expected_body
コード例 #2
0
ファイル: test_tasks.py プロジェクト: uetuluk/edx-platform
    def test_award_program_certificate(self, mock_get_api_base_url):
        """
        Ensure the correct API call gets made
        """
        mock_get_api_base_url.return_value = 'http://test-server/'
        student = UserFactory(username='******',
                              email='*****@*****.**')

        test_client = requests.Session()
        test_client.auth = SuppliedJwtAuth('test-token')

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

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

        expected_body = {
            'username':
            student.username,
            'lms_user_id':
            student.id,
            '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')
        assert json.loads(last_request_body) == expected_body