Show More
@@ -90,7 +90,8 b' def default_data(base_app):' | |||
|
90 | 90 | |
|
91 | 91 | |
|
92 | 92 | @pytest.fixture |
|
93 | def clean_tables(): | |
|
93 | def clean_tables(request): | |
|
94 | def fin(): | |
|
94 | 95 | tables = Base.metadata.tables.keys() |
|
95 | 96 | transaction.begin() |
|
96 | 97 | for t in tables: |
@@ -100,20 +101,23 b' def clean_tables():' | |||
|
100 | 101 | mark_changed(session) |
|
101 | 102 | transaction.commit() |
|
102 | 103 | |
|
104 | request.addfinalizer(fin) | |
|
105 | ||
|
103 | 106 | |
|
104 | 107 | @pytest.fixture |
|
105 | 108 | def default_user(): |
|
106 | 109 | from appenlight.models.user import User |
|
107 | 110 | from appenlight.models.auth_token import AuthToken |
|
108 | 111 | transaction.begin() |
|
112 | session = DBSession() | |
|
109 | 113 | user = User(id=1, |
|
110 | 114 | user_name='testuser', |
|
111 | 115 | status=1, |
|
112 | 116 | email='foo@barbaz99.com') |
|
113 |
|
|
|
117 | session.add(user) | |
|
114 | 118 | token = AuthToken(token='1234') |
|
115 | 119 | user.auth_tokens.append(token) |
|
116 | DBSession.flush() | |
|
120 | session.execute("SELECT nextval('users_id_seq')") | |
|
117 | 121 | transaction.commit() |
|
118 | 122 | return user |
|
119 | 123 | |
@@ -123,11 +127,12 b' def default_application(default_user):' | |||
|
123 | 127 | from appenlight.models.application import Application |
|
124 | 128 | |
|
125 | 129 | transaction.begin() |
|
130 | session = DBSession() | |
|
126 | 131 | application = Application( |
|
127 | 132 | resource_id=1, resource_name='testapp', api_key='xxxx') |
|
128 |
|
|
|
133 | session.add(application) | |
|
129 | 134 | default_user.resources.append(application) |
|
130 | DBSession.flush() | |
|
135 | session.execute("SELECT nextval('resources_resource_id_seq')") | |
|
131 | 136 | transaction.commit() |
|
132 | 137 | return application |
|
133 | 138 |
General Comments 0
You need to be logged in to leave comments.
Login now