[7196e71] | 1 | # |
---|
[cb9edc8] | 2 | # Copyright (C) 2020-2021 Soleta Networks <info@soleta.eu> |
---|
[7196e71] | 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 |
---|
[cb9edc8] | 6 | # Free Software Foundation; either version 3 of the License, or |
---|
| 7 | # (at your option) any later version. |
---|
[7196e71] | 8 | |
---|
| 9 | from server import Server |
---|
| 10 | from client import Client |
---|
| 11 | import unittest |
---|
| 12 | import json |
---|
| 13 | |
---|
| 14 | class TestRefreshMethods(unittest.TestCase): |
---|
| 15 | |
---|
| 16 | def test_correct_get(self): |
---|
[f86999d] | 17 | req = 'GET /refresh HTTP/1.0\r\nContent-Length: 0\r\n' + \ |
---|
| 18 | 'Content-Type: application/json\r\n\r\n' |
---|
[7196e71] | 19 | c = Client() |
---|
| 20 | s = Server() |
---|
| 21 | s.connect() |
---|
| 22 | s.send(req) |
---|
| 23 | client_response = s.recv() |
---|
| 24 | s.stop() |
---|
| 25 | c.stop() |
---|
| 26 | |
---|
| 27 | self.assertRegex(client_response, '^HTTP/1.0 200 OK\r\n*') |
---|
| 28 | client_response = client_response.split('\r\n\r\n') |
---|
| 29 | response_json = json.loads(client_response[1]) |
---|
| 30 | |
---|
| 31 | self.assertIn('partition_setup', response_json) |
---|
| 32 | self.assertIn('disk', response_json) |
---|
| 33 | |
---|
| 34 | # Check partition_setup parameters. |
---|
| 35 | for partition in response_json['partition_setup']: |
---|
| 36 | self.assertIn('filesystem', partition) |
---|
| 37 | self.assertIn('partition', partition) |
---|
| 38 | self.assertIn('format', partition) |
---|
| 39 | self.assertIn('code', partition) |
---|
| 40 | self.assertIn('size', partition) |
---|
| 41 | |
---|
| 42 | if __name__ == '__main__': |
---|
| 43 | unittest.main() |
---|