From 45374cd71db88c3a95e0e583f4f4c80ca5b12810 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Thu, 23 Aug 2018 19:24:11 +0800 Subject: [PATCH] fix #278: len_eq for content --- tests/httpbin/basic.yml | 10 ++++++++++ tests/test_api.py | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/tests/httpbin/basic.yml b/tests/httpbin/basic.yml index 6582e57b..2c64f175 100644 --- a/tests/httpbin/basic.yml +++ b/tests/httpbin/basic.yml @@ -89,5 +89,15 @@ validate: - eq: ["status_code", 200] +- test: + name: validate content length + request: + url: /spec.json + method: GET + validate: + - len_eq: ["content", 9] + - len_eq: ["json", 9] + - len_eq: ["text", 9] + diff --git a/tests/test_api.py b/tests/test_api.py index c127f5d2..a83a4cae 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -367,6 +367,12 @@ class TestHttpRunner(ApiServerUnittest): self.assertIsInstance(parsed_testcases, list) self.assertEqual(parsed_testcases[0]["config"]["name"], '12311') + def test_validate_response_content(self): + testcase_file_path = os.path.join( + os.getcwd(), 'tests/httpbin/basic.yml') + runner = HttpRunner().run(testcase_file_path) + self.assertTrue(runner.summary["success"]) + class TestLocustRunner(ApiServerUnittest):