Skip to content

Commit

Permalink
Address CR: factor out row deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
ihodes committed May 29, 2015
1 parent decd39a commit 8620446
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
11 changes: 11 additions & 0 deletions tests/python/helpers.py
@@ -0,0 +1,11 @@
"""Helpers for Python tests"""
import common.helpers


def delete_tables(engine, *table_names):
"""Delete all rows from tables in `table_names' in order."""
with common.helpers.tables(engine, *table_names) as tables:
connection = tables[0]
tables = tables[1:]
for table in tables:
table.delete().execute()
8 changes: 2 additions & 6 deletions tests/python/test_views.py
Expand Up @@ -5,6 +5,7 @@

from cycledash import app, db
from common.helpers import tables, find
from helpers import delete_tables
import cycledash.views

from test_projects_api import create_project_with_name
Expand Down Expand Up @@ -38,12 +39,7 @@ def setUp(self):
self.run = dict(res.fetchone())

def tearDown(self):
with tables(db.engine, 'projects', 'bams', 'vcfs', 'user_comments') \
as (con, projects, bams, runs, comments):
comments.delete().execute()
runs.delete().execute()
bams.delete().execute()
projects.delete().execute()
delete_tables(db.engine, 'user_comments', 'vcfs', 'bams', 'projects')
self.ctx.pop()
mocked.reset_mock()

Expand Down

0 comments on commit 8620446

Please sign in to comment.