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