source: OpenWorkouts-current/ow/tests/models/test_appmaker.py @ 5ec3a0b

currentfeature/docs
Last change on this file since 5ec3a0b was 5ec3a0b, checked in by borja <borja@…>, 5 years ago

Imported sources from the old python2-only repository:

  • Modified the code so it is python 3.6 compatible
  • Fixed deprecation warnings, pyramid 1.10.x supported now
  • Fixed deprecation warnings about some libraries, like pyramid-simpleform
  • Added pytest-pycodestyle and pytest-flakes for automatic checks on the source code files when running tests.
  • Added default pytest.ini setup to enforce some default parameters when running tests.
  • Cleaned up the code a bit, catched up with tests coverage.
  • Property mode set to 100644
File size: 950 bytes
Line 
1from unittest.mock import patch
2
3from ow.models import appmaker
4from ow.models.root import OpenWorkouts
5
6
7class TestAppMaker(object):
8
9    @patch('ow.models.transaction')
10    def test_appmaker(self, t):
11        """
12        Calling appmaker on a new zodb (without an OpenWorkouts root folder in
13        it), a new root object is added, the transaction is committed to the
14        zodb and the new root object is returned
15        """
16        zodb_root = {}
17        app = appmaker(zodb_root)
18        assert isinstance(app, OpenWorkouts)
19        assert t.commit.called
20
21    @patch('ow.models.transaction')
22    def test_appmaker_already_existing_root(self, t):
23        """
24        Calling appmaker with a zodb that has an OpenWorkouts root, nothing
25        changes in that zodb
26        """
27        zodb_root = {'app_root': 'faked-root-object'}
28        app = appmaker(zodb_root)
29        assert app == 'faked-root-object'
30        assert not t.commit.called
Note: See TracBrowser for help on using the repository browser.