aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--servo/tests/__init__.py7
-rw-r--r--servo/tests/test_filters.py0
-rw-r--r--servo/tests/test_forms.py20
-rw-r--r--servo/tests/test_functional.py2
-rw-r--r--servo/tests/test_models.py29
-rwxr-xr-xservo/tests/test_unit.py10
-rw-r--r--servo/tests/test_views.py7
7 files changed, 70 insertions, 5 deletions
diff --git a/servo/tests/__init__.py b/servo/tests/__init__.py
index e69de29..50d7153 100644
--- a/servo/tests/__init__.py
+++ b/servo/tests/__init__.py
@@ -0,0 +1,7 @@
+# -*- coding: utf-8 -*-
+"""This is the Servo tests package."""
+
+from test_unit import NoDbTestRunner
+
+
+__all__ = ['NoDbTestRunner']
diff --git a/servo/tests/test_filters.py b/servo/tests/test_filters.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/servo/tests/test_filters.py
diff --git a/servo/tests/test_forms.py b/servo/tests/test_forms.py
new file mode 100644
index 0000000..ef6ec1f
--- /dev/null
+++ b/servo/tests/test_forms.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+
+from django.test import TestCase, RequestFactory
+from django.contrib.auth.models import AnonymousUser
+from django.contrib.sessions.middleware import SessionMiddleware
+
+from servo.models.common import Configuration
+
+from servo.forms.checkin import CustomerForm
+
+from servo.tests.test_views import add_middleware_to_request
+
+
+class CheckinTestCase(TestCase):
+ def test_customer(self):
+ factory = RequestFactory()
+ request = factory.get('/checkin/')
+ request.user = AnonymousUser
+ request = add_middleware_to_request(request, SessionMiddleware)
+ form = CustomerForm(request)
diff --git a/servo/tests/test_functional.py b/servo/tests/test_functional.py
index 0fa5b49..201a582 100644
--- a/servo/tests/test_functional.py
+++ b/servo/tests/test_functional.py
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
-import os
import unittest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
+@unittest.skip
class NewVisitorTest(unittest.TestCase):
def setUp(self):
self.url = 'http://localhost:8000/checkin/'
diff --git a/servo/tests/test_models.py b/servo/tests/test_models.py
new file mode 100644
index 0000000..263834a
--- /dev/null
+++ b/servo/tests/test_models.py
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+
+import unittest
+from django.test import TestCase
+
+from servo.models.common import Configuration
+from servo.models.order import Order
+from servo.models.account import User
+
+
+class ConfigurationTests(TestCase):
+ def test_checkin_user(self):
+ uid = Configuration.conf('checkin_user')
+ u = User.objects.get(pk=uid)
+ self.assertEquals(u.pk, int(uid))
+
+
+class ServiceOrderTests(TestCase):
+ def test_checkin(self):
+ uid = Configuration.conf('checkin_user')
+ u = User.objects.get(pk=uid)
+ o = Order(created_by=u)
+ o.save()
+ o.check_in(u)
+ self.assertEquals(o.location, o.checkin_location)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/servo/tests/test_unit.py b/servo/tests/test_unit.py
index e7f4841..5e4daf3 100755
--- a/servo/tests/test_unit.py
+++ b/servo/tests/test_unit.py
@@ -1,15 +1,16 @@
# -*- coding: utf-8 -*-
import unittest
-from django.test import TestCase
+
from django.http import HttpRequest
from django.core.urlresolvers import resolve
-from django.test.simple import DjangoTestSuiteRunner
+from django.test import TestCase
+from django.test.runner import DiscoverRunner
from servo.views import checkin
-class NoDbTestRunner(DjangoTestSuiteRunner):
+class NoDbTestRunner(DiscoverRunner):
""" A test runner to test without database creation """
def setup_databases(self, **kwargs):
@@ -24,7 +25,8 @@ class NoDbTestRunner(DjangoTestSuiteRunner):
class ApiTest(TestCase):
pass
-
+
+@unittest.skip
class CheckinTest(TestCase):
def test_checkin_url_resolves(self):
found = resolve('/checkin/')
diff --git a/servo/tests/test_views.py b/servo/tests/test_views.py
new file mode 100644
index 0000000..290f3c4
--- /dev/null
+++ b/servo/tests/test_views.py
@@ -0,0 +1,7 @@
+# -*- coding: utf-8 -*-
+
+
+def add_middleware_to_request(request, middleware_class):
+ middleware = middleware_class()
+ middleware.process_request(request)
+ return request