Skip to content

Commit 4706c39

Browse files
committed
Merge pull request sclorg#28 from PI-Victor/pi-victor/tests
basic django example tests
2 parents 6f307eb + 878b187 commit 4706c39

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

welcome/tests.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
import os
2+
3+
from .models import PageView
4+
from .database import info
15
from django.test import TestCase
26

3-
# Create your tests here.
7+
# These basic tests are to be used as an example for running tests in S2I
8+
# and OpenShift when building an application image.
9+
class PageViewModelTest(TestCase):
10+
def test_viewpage_model(self):
11+
pageview = PageView.objects.create(hostname='localhost')
12+
pagetest = PageView.objects.get(hostname='localhost')
13+
self.assertEqual(pagetest.hostname, 'localhost')
14+
15+
class PageViewTest(TestCase):
16+
def test_index(self):
17+
resp = self.client.get('/')
18+
self.assertEqual(resp.status_code, 200)
19+
20+
class DbEngine(TestCase):
21+
def setUp(self):
22+
os.environ['ENGINE'] = 'SQLite'
23+
24+
def test_engine_setup(self):
25+
settings = info()
26+
self.assertEqual(settings['engine'], 'SQLite')
27+
self.assertEqual(settings['is_sqlite'], True)

0 commit comments

Comments
 (0)