GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#5)
by Bastien
01:09
created

ModelTest.setUp()   A

Complexity

Conditions 2

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
c 1
b 0
f 0
dl 0
loc 13
rs 9.4285
1
# -*- coding: utf-8 -*-
2
"""Unit test suite for the models of the application."""
3
4
from nose.tools import eq_
5
from pyjobsweb.model import DBSession
6
from pyjobsweb.tests import load_app
7
from pyjobsweb.tests import setup_db, teardown_db
8
9
__all__ = ['ModelTest']
10
11
12
def setup():
13
    """Setup test fixture for all model tests."""
14
    load_app()
15
    setup_db()
16
17
18
def teardown():
19
    """Tear down test fixture for all model tests."""
20
    teardown_db()
21
22
23
class ModelTest(object):
24
    """Base unit test case for the models."""
25
26
    klass = None
27
    attrs = {}
28
29
    def setUp(self):
30
        """Setup test fixture for each model test method."""
31
        try:
32
            new_attrs = {}
33
            new_attrs.update(self.attrs)
34
            new_attrs.update(self.do_get_dependencies())
35
            self.obj = self.klass(**new_attrs)
36
            DBSession.add(self.obj)
37
            DBSession.flush()
38
            return self.obj
39
        except:
40
            DBSession.rollback()
41
            raise
42
43
    def tearDown(self):
44
        """Tear down test fixture for each model test method."""
45
        DBSession.rollback()
46
47
    def do_get_dependencies(self):
48
        """Get model test dependencies.
49
50
        Use this method to pull in other objects that need to be created
51
        for this object to be build properly.
52
53
        """
54
        return {}
55
56
    def test_create_obj(self):
57
        """Model objects can be created"""
58
        pass
59
60
    def test_query_obj(self):
61
        """Model objects can be queried"""
62
        obj = DBSession.query(self.klass).one()
63
        for key, value in self.attrs.items():
64
            eq_(getattr(obj, key), value)
65