Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/CeibalEncuestaWeb/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'CeibalEncuestaWeb/tests.py')
-rw-r--r--CeibalEncuestaWeb/tests.py26
1 files changed, 22 insertions, 4 deletions
diff --git a/CeibalEncuestaWeb/tests.py b/CeibalEncuestaWeb/tests.py
index bfc18d3..1fed945 100644
--- a/CeibalEncuestaWeb/tests.py
+++ b/CeibalEncuestaWeb/tests.py
@@ -1,8 +1,19 @@
import unittest
import socket
+import contextlib
+import sys
from fabric.api import local
+from CeibalEncuesta import WebServer
+
+
+@contextlib.contextmanager
+def redirect_stdout(stream):
+ sys.stdout = sys.stderr = stream
+ yield
+ sys.stdout = sys.__stdout__
+
class ContainerTest(unittest.TestCase):
@@ -22,18 +33,25 @@ class ContainerTest(unittest.TestCase):
result = self.result
self.assertIn('Opening browser', result)
-@unittest.skip("waiting implementation")
+
class WebServerTest(unittest.TestCase):
def test_connection(self):
- s = socket.socket()
+ with open('/dev/null') as null:
+ with redirect_stdout(null):
+ webserver = WebServer()
+ webserver.start()
+
try:
+ s = socket.socket()
s.connect(("localhost", 9004))
- except Exception:
- self.fail("Can't connect to web server")
+ except Exception as e:
+ self.fail(e)
finally:
s.close()
+ webserver.stop()
if __name__ == '__main__':
unittest.main()
+