[llvm-commits] [zorg] r125867 - in /zorg/trunk/llvmlab/tests: ./ basic.py
Daniel Dunbar
daniel at zuster.org
Fri Feb 18 08:40:58 PST 2011
Author: ddunbar
Date: Fri Feb 18 10:40:58 2011
New Revision: 125867
URL: http://llvm.org/viewvc/llvm-project?rev=125867&view=rev
Log:
llvmlab: Add some simple tests.
Added:
zorg/trunk/llvmlab/tests/
zorg/trunk/llvmlab/tests/basic.py
Added: zorg/trunk/llvmlab/tests/basic.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/llvmlab/tests/basic.py?rev=125867&view=auto
==============================================================================
--- zorg/trunk/llvmlab/tests/basic.py (added)
+++ zorg/trunk/llvmlab/tests/basic.py Fri Feb 18 10:40:58 2011
@@ -0,0 +1,54 @@
+import os
+import unittest
+
+import llvmlab
+from llvmlab.ui import app
+
+class TestCase(unittest.TestCase):
+ def setUp(self):
+ self.app = app.App.create_test_instance().test_client()
+
+ def tearDown(self):
+ pass
+
+ def login(self, username, password):
+ return self.app.post('/login', data=dict(
+ username=username,
+ password=password), follow_redirects=True)
+
+ def logout(self):
+ return self.app.get('/logout', follow_redirects=True)
+
+class TestBasic(TestCase):
+ def test_index(self):
+ rv = self.app.get('/')
+ assert rv.data.startswith('<!DOCTYPE')
+
+ def test_login_sequence(self):
+ # Check that we aren't initially logged in.
+ rv = self.app.get('/')
+ assert "Logged in" not in rv.data
+
+ # Check that the users page doesn't show up.
+ rv = self.app.get('/users')
+ assert """You must <a href="/login">login</a>.""" in rv.data
+
+ # Check that the login page shows what we expect.
+ rv = self.app.get('/login')
+ assert """<input type=text name=username>""" in rv.data
+
+ # Log in as the test admin user.
+ rv = self.login("admin", "admin")
+ assert "Logged In: <i>admin</i>""" in rv.data
+
+ # Check that we can access the users page now.
+ rv = self.app.get('/users')
+ assert """You must <a href="/login">login</a>.""" not in rv.data
+ assert """<td>Administrator</td>""" in rv.data
+
+ # Log out.
+ rv = self.logout()
+ assert "Logged in" not in rv.data
+
+if __name__ == '__main__':
+ unittest.main()
More information about the llvm-commits
mailing list