source: ogClient-Git/tests/units/test_0005_other_requests.py @ 7196e71

Last change on this file since 7196e71 was a5ce597, checked in by Alvaro Neira Ayuso <aneira@…>, 5 years ago

Add test for non-existent function

  • Property mode set to 100644
File size: 1.1 KB
RevLine 
[a5ce597]1#
2# Copyright (C) 2020 Soleta Networks <info@soleta.eu>
3#
4# This program is free software: you can redistribute it and/or modify it under
5# the terms of the GNU Affero General Public License as published by the
6# Free Software Foundation, version 3.
7#
8
9from server import Server
10from client import Client
11import unittest
12
13class TestOtherRequests(unittest.TestCase):
14
15    def test_non_existent_function(self):
16        post_req = 'POST /this_function_does_not_exist HTTP/1.0\r\n' + \
17                   'Content-Length:0\r\nContent-Type:application/json\r\n\r\n'
18        get_req = 'GET /this_function_does_not_exist HTTP/1.0\r\n' + \
19                  'Content-Length:0\r\nContent-Type:application/json\r\n\r\n'
20        c = Client()
21        s = Server()
22        s.connect()
23        s.send(post_req)
24        post_response = s.recv()
25        s.send(get_req)
26        get_response = s.recv()
27        s.stop()
28        c.stop()
29        self.assertRegex(post_response, '^HTTP/1.0 400 Bad Request\r\n*')
30        self.assertRegex(get_response, '^HTTP/1.0 400 Bad Request\r\n*')
31
32if __name__ == '__main__':
33    unittest.main()
Note: See TracBrowser for help on using the repository browser.