Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/CeibalEncuestaWeb/tests.py
diff options
context:
space:
mode:
authorCode Raguet <ignacio.code@gmail.com>2013-07-04 18:51:36 (GMT)
committer Code Raguet <ignacio.code@gmail.com>2013-07-04 18:58:59 (GMT)
commit2f4887b4394f2d093309f6c24daea6b46b4478d4 (patch)
tree29d885e9454d6f86be649f482f322a1dde33a08f /CeibalEncuestaWeb/tests.py
parent57444bf738bab7d367d552b59a20943b607a029b (diff)
add webser and venv requirements (for pip)
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()
+