Beispiel #1
0
 def test_view_gets_decoded_instance(self):
     person = self.person_cls("Bob", "Smith")
     
     with self.test_client as c:
         res = c.post("/person", data=encode.dumper(person), content_type="application/json")
         self.assertIsInstance(request._get_current_object(), JsonWebRequest)            
         self.assertIsInstance(request.json, self.person_cls)
         
     self.assertEqual(res.status_code, 200)
Beispiel #2
0
    def test_view_gets_decoded_instance(self):
        person = self.person_cls("Bob", "Smith")

        with self.test_client as c:
            res = c.post("/person",
                         data=encode.dumper(person),
                         content_type="application/json")
            self.assertIsInstance(request._get_current_object(),
                                  JsonWebRequest)
            self.assertIsInstance(request.json, self.person_cls)

        self.assertEqual(res.status_code, 200)
Beispiel #3
0
def get_request(obj):
    builder = EnvironBuilder("/", data=encode.dumper(obj))
    builder.headers["content-type"] = "application/json" 
    return JsonWebRequest(builder.get_environ())
Beispiel #4
0
 def test_wrong_content_type_returns_error(self):
     res = self.test_client.post("/person", 
                                 data=encode.dumper(self.person_cls(1, "smith")))
     
     self.assertEqual(res.status_code, 400)
Beispiel #5
0
 def post(self, url, data):
     return self.test_client.post(url, data=encode.dumper(data), 
                                  content_type="application/json")
Beispiel #6
0
 def post(self, url, data):
     return self.test_client.post(url,
                                  data=encode.dumper(data),
                                  content_type="application/json")
Beispiel #7
0
def get_request(obj):
    builder = EnvironBuilder("/", data=encode.dumper(obj))
    builder.headers["content-type"] = "application/json"
    return JsonWebRequest(builder.get_environ())
Beispiel #8
0
    def test_wrong_content_type_returns_error(self):
        res = self.test_client.post("/person",
                                    data=encode.dumper(
                                        self.person_cls(1, "smith")))

        self.assertEqual(res.status_code, 400)