source: ogClient-Git/tests/units/test_0007_software.py @ 87c2a6a

Last change on this file since 87c2a6a was f86999d, checked in by Alvaro Neira Ayuso <aneira@…>, 5 years ago

add space after Content-Length and Content-Type

ogAdmServer needs this space to work fine.

  • Property mode set to 100644
File size: 1.1 KB
Line 
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
12import json
13
14class TestSoftwareMethods(unittest.TestCase):
15
16    def test_correct_post(self):
17        req_json = '{"disk": 1, "partition": 1}'
18        req = 'POST /software HTTP/1.0\r\nContent-Length: ' + \
19              str(len(req_json)) + \
20              '\r\nContent-Type: application/json\r\n\r\n' + req_json
21        c = Client()
22        s = Server()
23        s.connect()
24        s.send(req)
25        client_response = s.recv()
26        s.stop()
27        c.stop()
28
29        self.assertRegex(client_response, '^HTTP/1.0 200 OK\r\n*')
30        client_response = client_response.split('\r\n\r\n')
31        response_json = json.loads(client_response[1])
32
33        self.assertIn('partition', response_json)
34        self.assertIn('software', response_json)
35        self.assertIn('disk', response_json)
36
37if __name__ == '__main__':
38    unittest.main()
Note: See TracBrowser for help on using the repository browser.