Ejemplo n.º 1
0
    def test_can_be_create_request(self):

        torneira_client = TestingClient()
        request = torneira_client.create_request(uri="/should-be-url", method="GET")

        self.assertEquals(request.uri, "/should-be-url")
        self.assertEquals(request.method, "GET")
Ejemplo n.º 2
0
    def test_should_respect_status_code(self):
        settings.ROOT_URLS = "functional.testing.test_client"
        client = TestingClient()
        response = client.get("/should-respect-status-code")

        self.assertEquals(response.code, 201)
        settings.ROOT_URLS = ""
Ejemplo n.º 3
0
    def test_can_be_make_request_with_500_error(self):

        settings.ROOT_URLS = "functional.testing.test_client"

        torneira_client = TestingClient()

        response = torneira_client.get("/should-be-url-error")

        self.assertEquals(response.code, 500)

        settings.ROOT_URLS = ""
Ejemplo n.º 4
0
    def test_can_be_make_async_request(self):

        settings.ROOT_URLS = "functional.testing.test_client"

        torneira_client = TestingClient()

        response = torneira_client.get("/should-be-async-url")

        self.assertEquals(response.body, "should be async response")
        self.assertEquals(response.code, 200)

        settings.ROOT_URLS = ""
Ejemplo n.º 5
0
    def test_can_be_make_request_post(self):

        settings.ROOT_URLS = "functional.testing.test_client"

        torneira_client = TestingClient()

        response = torneira_client.post("/should-be-post", {"should_be_parameter": "ShouldBePostData"})

        self.assertEquals(response.body, "should be response --- ShouldBePostData")
        self.assertEquals(response.code, 200)

        settings.ROOT_URLS = ""
Ejemplo n.º 6
0
    def test_can_convert_dict_wtih_list_to_post_data(self):
        data = {
            'name': 'should be name',
            'status': 1,
            'itens': [1, 4, 3]
        }

        parsed_data = TestingClient.parse_post_data(data)
        expected_data = 'status=1&itens=1&itens=4&itens=3&name=should+be+name'
        self.assertEquals(parsed_data, expected_data)
Ejemplo n.º 7
0
    def test_can_convert_dict_with_list_to_post_data(self):
        data = {
            'name': 'should be name',
            'status': 1,
            'itens': [1, 4, 3]
        }

        parsed_data = TestingClient.parse_post_data(data)
        self.assertTrue('status=1' in parsed_data)
        self.assertTrue('itens=1' in parsed_data)
        self.assertTrue('itens=4' in parsed_data)
        self.assertTrue('itens=3' in parsed_data)
        self.assertTrue('name=should+be+name' in parsed_data)