Пример #1
0
    def test_student_single_exercise_editor(self, patch):
        patch.return_value = Exercise.objects.create(description='Dummy description')

        response = self.client.get(reverse(student_single_exercise_editor, args=('1',)))

        self.assertEqual(200, response.status_code)
        self.assertTrue('ex_description' in response.context)
        self.assertEqual('Dummy description', response.context['ex_description'])
        patch.assert_called_with(ex_id='1')
Пример #2
0
 def test_rest_client_patch(self, patch):
     """
     Verifies that the patch method invokes the corresponding method on the
     rest client object
     """
     from ..rest import RESTClient
     client = RESTClient()
     client.PATCH()
     patch.assert_called_with()
Пример #3
0
 def test_rest_client_patch(self, patch):
     """
     Verifies that the patch method invokes the corresponding method on the
     rest client object
     """
     from ..rest import RESTClient
     client = RESTClient()
     client.PATCH()
     patch.assert_called_with()
 def test_request_method(self, delete, put, patch, post, head, get):
     """
     Verify that the correct client method is called with the right kwargs
     """
     query_params = {'query': 'query_param'}
     post_params = {'post': 'post_param'}
     body = 'body'
     self.client.request(
         'GET', 'some_url', query_params=query_params, body=body,
         post_params=post_params, headers=self.base_expected_headers)
     self.client.request(
         'HEAD', 'some_url', query_params=query_params, body=body,
         post_params=post_params, headers=self.base_expected_headers)
     self.client.request(
         'POST', 'some_url', query_params=query_params, body=body,
         post_params=post_params, headers=self.base_expected_headers)
     self.client.request(
         'PATCH', 'some_url', query_params=query_params, body=body,
         post_params=post_params, headers=self.base_expected_headers)
     self.client.request(
         'PUT', 'some_url', query_params=query_params, body=body,
         post_params=post_params, headers=self.base_expected_headers)
     self.client.request(
         'DELETE', 'some_url', query_params=query_params, body=body,
         post_params=post_params, headers=self.base_expected_headers)
     delete.assert_called_with(
         'some_url', query_params=query_params,
         headers=self.base_expected_headers)
     put.assert_called_with(
         'some_url', post_params=post_params, body=body,
         headers=self.base_expected_headers)
     patch.assert_called_with(
         'some_url', post_params=post_params, body=body,
         headers=self.base_expected_headers)
     post.assert_called_with(
         'some_url', post_params=post_params, body=body,
         headers=self.base_expected_headers)
     head.assert_called_with(
         'some_url', query_params=query_params,
         headers=self.base_expected_headers)
     get.assert_called_with(
         'some_url', query_params=query_params,
         headers=self.base_expected_headers)
     n = ['NOT_A_METHOD', 'some_url']
     self.assertRaises(ValueError, partial(self.client.request, *n))
 def test_request_method(self, delete, put, patch, post, head, get):
     """
     Verify that the correct client method is called with the right kwargs
     """
     query_params = {'query': 'query_param'}
     post_params = {'post': 'post_param'}
     body = 'body'
     self.client.request('GET',
                         'some_url',
                         query_params=query_params,
                         body=body,
                         post_params=post_params,
                         headers=self.base_expected_headers)
     self.client.request('HEAD',
                         'some_url',
                         query_params=query_params,
                         body=body,
                         post_params=post_params,
                         headers=self.base_expected_headers)
     self.client.request('POST',
                         'some_url',
                         query_params=query_params,
                         body=body,
                         post_params=post_params,
                         headers=self.base_expected_headers)
     self.client.request('PATCH',
                         'some_url',
                         query_params=query_params,
                         body=body,
                         post_params=post_params,
                         headers=self.base_expected_headers)
     self.client.request('PUT',
                         'some_url',
                         query_params=query_params,
                         body=body,
                         post_params=post_params,
                         headers=self.base_expected_headers)
     self.client.request('DELETE',
                         'some_url',
                         query_params=query_params,
                         body=body,
                         post_params=post_params,
                         headers=self.base_expected_headers)
     delete.assert_called_with('some_url',
                               query_params=query_params,
                               headers=self.base_expected_headers)
     put.assert_called_with('some_url',
                            post_params=post_params,
                            body=body,
                            headers=self.base_expected_headers)
     patch.assert_called_with('some_url',
                              post_params=post_params,
                              body=body,
                              headers=self.base_expected_headers)
     post.assert_called_with('some_url',
                             post_params=post_params,
                             body=body,
                             headers=self.base_expected_headers)
     head.assert_called_with('some_url',
                             query_params=query_params,
                             headers=self.base_expected_headers)
     get.assert_called_with('some_url',
                            query_params=query_params,
                            headers=self.base_expected_headers)
     n = ['NOT_A_METHOD', 'some_url']
     self.assertRaises(ValueError, partial(self.client.request, *n))