Philipp Schrader | 684a8e8 | 2022-02-25 17:39:28 -0800 | [diff] [blame] | 1 | # TODO(phil): Delete this and replace it with a selenium test. Preferably |
| 2 | # written in either Javascript or Go. |
| 3 | |
| 4 | import socket |
| 5 | import subprocess |
| 6 | import time |
| 7 | import unittest |
| 8 | import urllib.request |
| 9 | |
| 10 | class TestDebugCli(unittest.TestCase): |
| 11 | |
| 12 | def setUp(self): |
| 13 | self.webserver = subprocess.Popen(["scouting/scouting"]) |
| 14 | |
| 15 | # Wait for the server to respond to requests. |
| 16 | while True: |
| 17 | try: |
| 18 | connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
| 19 | connection.connect(("localhost", 8080)) |
| 20 | connection.close() |
| 21 | break |
| 22 | except ConnectionRefusedError: |
| 23 | connection.close() |
| 24 | time.sleep(0.01) |
| 25 | |
| 26 | def tearDown(self): |
| 27 | self.webserver.terminate() |
| 28 | self.webserver.wait() |
| 29 | |
| 30 | def test_index_html(self): |
| 31 | """Makes sure that we the scouting server is serving our main index.html file.""" |
| 32 | with urllib.request.urlopen("http://localhost:8080/") as file: |
| 33 | html = file.read().decode("utf-8") |
| 34 | self.assertIn("<my-app></my-app>", html) |
| 35 | |
| 36 | |
| 37 | if __name__ == "__main__": |
| 38 | unittest.main() |