Skip to content

Commit

Permalink
Moved sample data out of fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
Digant C Kasundra committed May 13, 2015
1 parent 7576f6d commit 44a0340
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
13 changes: 2 additions & 11 deletions tests/model_tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@pytest.fixture
def db_engine(tmpdir):
db_path = tmpdir.join("hermes.sqlite")
db_engine = models.get_db_engine("sqlite:///%s" % db_path)
db_engine = models.get_db_engine("sqlite:///%s" % db_path, echo=True)

return db_engine

Expand All @@ -21,13 +21,4 @@ def fin():
session.close()
request.addfinalizer(fin)

return session

@pytest.fixture
def sample_data1(session):
session.flush()
sql_file = open('tests/sample_data/sample_data1.sql')
sql = sql_file.read()
for statement in sql.split(";"):
scrubbed = re.sub(r'[\t\n]', ' ', statement)
session.execute(scrubbed)
return session
19 changes: 16 additions & 3 deletions tests/model_tests/test_fates.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
import pytest
import re
from sqlalchemy.exc import IntegrityError

from hermes import exc
from hermes import models

from .fixtures import db_engine, session, sample_data1
from .fixtures import db_engine, session


def test_creation(session, sample_data1):
def setup_sampledata1(session):
sql_file = open('tests/sample_data/sample_data1.sql')
sql = sql_file.read()
for statement in sql.split(";"):
scrubbed = re.sub(r'[\t\n]', ' ', statement)
session.execute(scrubbed)


def test_creation(session):
setup_sampledata1(session)

event_types = session.query(models.EventType).all()
assert len(event_types) == 4

Expand All @@ -28,7 +39,9 @@ def test_creation(session, sample_data1):
assert fate.description == "New fate"


def test_duplicate(session, sample_data1):
def test_duplicate(session):
setup_sampledata1(session)

event_types = session.query(models.EventType).all()
assert len(event_types) == 4

Expand Down

0 comments on commit 44a0340

Please sign in to comment.