source: OpenWorkouts-current/ow/tests/test_security.py @ 929097a

currentfeature/docs
Last change on this file since 929097a 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: 709 bytes
Line 
1import pytest
2
3from pyramid.testing import DummyRequest
4
5from ow.security import groupfinder
6from ow.models.root import OpenWorkouts
7from ow.models.user import User
8
9
10class TestSecurity(object):
11
12    @pytest.fixture
13    def root(self):
14        root = OpenWorkouts()
15        root['john'] = User(firstname='John', lastname='Doe',
16                            email='john.doe@example.net')
17        root['john'].password = 's3cr3t'
18        return root
19
20    def test_groupfinder(self, root):
21        request = DummyRequest()
22        request.root = root
23        # User does exist
24        assert groupfinder('john', request) == ['john']
25        # User does not exist
26        assert groupfinder('jack', request) == []
Note: See TracBrowser for help on using the repository browser.