Example #1
0
    def test_methods_argument_allows_given_methods(self):
        response = self.client.get('/simple_get_and_post/')
        self.assertEqual(response.status_code, 200)

        response = self.client.post('/simple_get_and_post/')
        self.assertEqual(response.status_code, 200)

        json.loads(response.content)
Example #2
0
    def test_methods_argument_denies_blocked_methods(self):
        response = self.client.delete('/simple_get_and_post/')
        self.assertEqual(response.status_code, 405)

        response = self.client.put('/simple_get_and_post/')
        self.assertEqual(response.status_code, 405)

        json.loads(response.content)
Example #3
0
    def test_simple_post_failure(self):
        response = self.client.get('/simple_bool_post/')
        self.assertEqual(response.status_code, 405)

        response = self.client.get('/simple_post/')
        self.assertEqual(response.status_code, 405)

        json.loads(response.content)
Example #4
0
    def test_simple_post_success(self):
        response = self.client.post('/simple_bool_post/')
        self.assertEqual(response.status_code, 200)

        response = self.client.post('/simple_post/')
        self.assertEqual(response.status_code, 200)

        json.loads(response.content)
Example #5
0
    def test_custom_status_code(self):
        response = self.client.get('/custom/712/')
        self.assertEqual(response.status_code, 712)

        json.loads(response.content)
Example #6
0
    def test_catch_http_404_exception(self):
        response = self.client.get('/raise/404/')
        self.assertEqual(response.status_code, 404)

        json.loads(response.content)
Example #7
0
    def test_logged_failure(self):
        response = self.client.get('/logged/')
        self.assertEqual(response.status_code, 401)

        json.loads(response.content)
Example #8
0
    def test_logged_success(self):
        self.client.login(username='******', password='******')
        response = self.client.get('/logged/')
        self.assertEqual(response.status_code, 200)

        json.loads(response.content)
Example #9
0
    def test_simple(self):
        response = self.client.get('/simple/')
        self.assertEqual(response.status_code, 200)

        json.loads(response.content)