Exemple #1
0
class TestClient(unittest.TestCase):
    def setUp(self):
        self.app = mock_app_builder()
        self.client = Client(self.app)

    def test_create_client(self):
        app = mock_app_builder()
        client = Client(app)
        self.assertTrue(client.app)

    @inlineCallbacks
    def test_get_request(self):
        response = yield self.client.get("/testing/")
        self.assertEqual(response.content, b"Something")
        self.assertTrue(len(response.headers) > 3)

    @inlineCallbacks
    def test_get_request_with_params(self):
        response = yield self.client.get("/testing/", {"q": "query"})
        self.assertEqual(response.content, b"Something")
        self.assertTrue(len(response.headers) > 3)

    @inlineCallbacks
    def test_post_request(self):
        response = yield self.client.post("/testing/")
        self.assertEqual(response.content, b"Something posted")
        self.assertTrue(len(response.headers) > 3)

    @inlineCallbacks
    def test_put_request(self):
        response = yield self.client.put("/testing/")
        self.assertEqual(response.content, b"Something put")
        self.assertTrue(len(response.headers) > 3)

    @inlineCallbacks
    def test_head_request(self):
        response = yield self.client.head("/testing/")
        self.assertEqual(response.content, b"")
        self.assertTrue(len(response.headers) > 3)

    @inlineCallbacks
    def test_delete_request(self):
        response = yield self.client.delete("/testing/")
        self.assertEqual(response.content, b"")
        self.assertTrue(len(response.headers) > 3)

    @inlineCallbacks
    def test_get_deferred_request(self):
        response = yield self.client.get("/deferred_testing/")
        self.assertEqual(response.content, b"Something...done!")
        self.assertTrue(len(response.headers) > 3)

    @inlineCallbacks
    def test_cookies(self):
        response = yield self.client.get("/cookie_testing/")
        self.assertEqual(self.client.cookies.get_secure_cookie("test_cookie"),
                         b"test_value")

        response = yield self.client.post("/cookie_testing/")
        self.assertEqual(response.content, b"test_value")
Exemple #2
0
class TestClient(unittest.TestCase):
    def setUp(self):
        self.app = mock_app_builder()
        self.client = Client(self.app)

    def test_create_client(self):
        app = mock_app_builder()
        client = Client(app)
        self.assertTrue(client.app)

    @inlineCallbacks
    def test_get_request(self):
        response = yield self.client.get("/testing/")
        self.assertEqual(response.content, "Something")
        self.assertTrue(len(response.headers) > 3)

    @inlineCallbacks
    def test_get_request_with_params(self):
        response = yield self.client.get("/testing/", {"q": "query"})
        self.assertEqual(response.content, "Something")
        self.assertTrue(len(response.headers) > 3)

    @inlineCallbacks
    def test_post_request(self):
        response = yield self.client.post("/testing/")
        self.assertEqual(response.content, "Something posted")
        self.assertTrue(len(response.headers) > 3)

    @inlineCallbacks
    def test_put_request(self):
        response = yield self.client.put("/testing/")
        self.assertEqual(response.content, "Something put")
        self.assertTrue(len(response.headers) > 3)

    @inlineCallbacks
    def test_head_request(self):
        response = yield self.client.head("/testing/")
        self.assertEqual(response.content, "")
        self.assertTrue(len(response.headers) > 3)

    @inlineCallbacks
    def test_delete_request(self):
        response = yield self.client.delete("/testing/")
        self.assertEqual(response.content, "")
        self.assertTrue(len(response.headers) > 3)

    @inlineCallbacks
    def test_get_deferred_request(self):
        response = yield self.client.get("/deferred_testing/")
        self.assertEqual(response.content, "Something...done!")
        self.assertTrue(len(response.headers) > 3)
Exemple #3
0
 def test_create_client(self):
     app = mock_app_builder()
     client = Client(app)
     self.assertTrue(client.app)
Exemple #4
0
 def setUp(self):
     self.app = mock_app_builder()
     self.client = Client(self.app)
Exemple #5
0
 def setUp(self):
     self.app = mock_app_builder()
     self.client = Client(self.app)