Good afternoon guys. I can't do my python test at all ((in the main.py file I added code:
def main(req): print('!__REQ:', req) return "ff" In the file test.py added:
import unittest from main import main class TestMethods(unittest.TestCase): REQUEST = { "GET_POSTS": """GET /api/v1/posts HTTP/1.1""", "POST_POSTS": """POST /api/v1/posts HTTP/1.1 title=TestTitle1""", "GET_404": """GET /api/v1/gimme404 HTTP/1.1""", } RESPONSE = { "EMPTY_200": """HTTP/1.1 200 OK []""", "404": "HTTP/1.1 404 Not Found", "GET_POSTS": """HTTP/1.1 200 OK [{"id": "1", "title": "TestTitle1"}]""" } def test_empty_get(self): self.assertEqual(self.RESPONSE['EMPTY_200'], main(self.REQUEST['GET_POSTS'])) def test_404_get(self): self.assertEqual(self.RESPONSE['404'], main(self.REQUEST['GET_404'])) def test_post_and_get(self): main(self.REQUEST['POST_POSTS']) self.assertEqual(self.RESPONSE['GET_POSTS'], main(self.REQUEST['GET_POSTS'])) if __name__ == '__main__': unittest.main() and when I try to run it, it gives me errors like:
FAIL: test_404_get ( main .TestMethods)
Traceback (most recent call last): File "C:/Users/ROGER/Desktop/python-test-project/test.py", line 29, in test_404_get self.assertEqual(self.RESPONSE['404'], main(self.REQUEST['GET_404'])) AssertionError: 'HTTP/1.1 404 Not Found' != 'ff' - HTTP/1.1 404 Not Found + ff What does this mean?