##// 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 92 @pytest.fixture
93 def clean_tables():
94 tables = Base.metadata.tables.keys()
95 transaction.begin()
96 for t in tables:
97 if not t.startswith('alembic_'):
98 DBSession.execute('truncate %s cascade' % t)
99 session = DBSession()
100 mark_changed(session)
101 transaction.commit()
93 def clean_tables(request):
94 def fin():
95 tables = Base.metadata.tables.keys()
96 transaction.begin()
97 for t in tables:
98 if not t.startswith('alembic_'):
99 DBSession.execute('truncate %s cascade' % t)
100 session = DBSession()
101 mark_changed(session)
102 transaction.commit()
103
104 request.addfinalizer(fin)
102 105
103 106
104 107 @pytest.fixture
@@ -106,14 +109,15 b' 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 DBSession.add(user)
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 DBSession.add(application)
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