blob: 3b62224086f443254278e68a83a151c55dad8e6f [file] [log] [blame]
Philipp Schrader684a8e82022-02-25 17:39:28 -08001# TODO(phil): Delete this and replace it with a selenium test. Preferably
2# written in either Javascript or Go.
3
4import socket
5import subprocess
6import time
7import unittest
8import urllib.request
9
10class 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
37if __name__ == "__main__":
38 unittest.main()