Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: fuzzy-id/wp_frontend
base: 6ece069f2e
...
head fork: fuzzy-id/wp_frontend
compare: 0d4f9e8f28
  • 2 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
17 wp_frontend/tests/__init__.py
View
@@ -30,23 +30,6 @@ def db_resetter(inst):
return f(inst)
return db_resetter
-class BaseTestWithDB(unittest.TestCase):
-
- def setUp(self):
- self.transaction = getTransaction()
- self.session = createEngineAndInitDB()
- self.config = testing.setUp()
-
- def tearDown(self):
- self.session.remove()
- testing.tearDown()
-
- def _add_one(self, *args):
- self.transaction.begin()
- entry = self._make_the_class(*args)
- self.session.add(entry)
- self.transaction.commit()
-
def createEngineAndInitDB(sql_url=sql_url,
sql_echo=False):
engine = create_engine(sql_url, echo=sql_echo)
1  wp_frontend/tests/test_get_data.py
View
@@ -9,7 +9,6 @@
from wp_frontend.models import get_data
from wp_frontend.models.calculations import CurrKW
from wp_frontend import tests
-from wp_frontend.tests import BaseTestWithDB
from wp_frontend.tests import create_entries
from wp_frontend.views import wp_datetime
33 wp_frontend/tests/test_set_data.py
View
@@ -1,25 +1,40 @@
# -*- coding: utf-8 -*-
import datetime
+import unittest
+from pyramid import testing
+
from wp_frontend.models import set_data
-from wp_frontend.tests import BaseTestWithDB
+from wp_frontend import tests
from wp_frontend.views.wp_datetime import strip_ms
-class DataToSetTest(BaseTestWithDB):
+class DataToSetTest(unittest.TestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ tmp_session = tests.create_engine_and_init_db(db_reset=True)
+ tmp_session.remove()
+
+ def setUp(self):
+ self.transaction = tests.getTransaction()
+ self.session = tests.create_engine_and_init_db()
+ self.config = testing.setUp()
- def _make_the_class(self, *args):
- return set_data.DataToSet(*args)
+ def tearDown(self):
+ self.session.remove()
+ testing.tearDown()
+
+ def _add_one(self, *args):
+ self.transaction.begin()
+ entry = set_data.DataToSet(*args)
+ self.session.add(entry)
+ self.transaction.commit()
def _get_last_entry(self):
query = self.session.query(set_data.DataToSet)
query = query.order_by(set_data.DataToSet.id.desc())
return query.first()
- def test_db_empty_on_startup(self):
- query = self.session.query(set_data.DataToSet)
- entries = query.all()
- self.assertRaises(IndexError, entries.pop)
-
def test_get_last_entry_works(self):
self._add_one('test_user', 'Hzg:TempEinsatz', '23', '80')
entry = self._get_last_entry()
44 wp_frontend/tests/test_views.py
View
@@ -7,9 +7,10 @@
import wp_frontend.views.graphs
from pyramid import testing
from wp_frontend import views
+from wp_frontend import tests
+from wp_frontend.tests import create_entries
from wp_frontend.models import calculations
from wp_frontend.models import get_data, helpers
-from wp_frontend.tests import BaseTestWithDB, create_entries
from wp_frontend.views import wp_datetime, set_val
class RootViewTest(unittest.TestCase):
@@ -26,11 +27,29 @@ def test_forward_via_view_home(self):
response = views.view_wp(request)
self.assertEqual(response.location, '/home')
-class ViewHomeTests(BaseTestWithDB):
+class ViewHomeTests(unittest.TestCase):
- def _make_the_class(self, *args):
- return get_data.PulledData(*args)
+ @classmethod
+ def setUpClass(cls):
+ tmp_session = tests.create_engine_and_init_db(db_reset=True)
+ tmp_session.remove()
+ def setUp(self):
+ self.transaction = tests.getTransaction()
+ self.session = tests.create_engine_and_init_db()
+ self.config = testing.setUp()
+
+ def tearDown(self):
+ self.session.remove()
+ testing.tearDown()
+
+ def _add_one(self, *args):
+ self.transaction.begin()
+ entry = get_data.PulledData(*args)
+ self.session.add(entry)
+ self.transaction.commit()
+
+ @tests.reset_db
def test_view_home_without_data(self):
request = testing.DummyRequest()
response = views.view_home(request)
@@ -81,8 +100,23 @@ def test_view_home_with_data(self):
self.maxDiff = None
self.assertDictEqual(result, data_now)
-class ViewSetValTests(BaseTestWithDB):
+class ViewSetValTests(unittest.TestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ tmp_session = tests.create_engine_and_init_db(db_reset=True)
+ tmp_session.remove()
+
+ def setUp(self):
+ self.transaction = tests.getTransaction()
+ self.session = tests.create_engine_and_init_db()
+ self.config = testing.setUp()
+
+ def tearDown(self):
+ self.session.remove()
+ testing.tearDown()
+ @tests.reset_db
def test_view_without_data_present(self):
request = testing.DummyRequest()

No commit comments for this range

Something went wrong with that request. Please try again.