Skip to content

Commit

Permalink
test case to auto_commit
Browse files Browse the repository at this point in the history
  • Loading branch information
chfw committed Jun 30, 2015
1 parent eb105de commit 00036fb
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/test_sql_book.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def test_invalid_parameters(self):

SQLTableWriter(mysession,
[Pyexcel,self.data[0], mapdict, None, None])
mysession.close()


class TestMultipleRead:
Expand Down Expand Up @@ -280,3 +281,33 @@ def test_sql(self):
assert data == content
mysession.close()


class TestDisabledWrite:
def setUp(self):
Base.metadata.drop_all(engine)
Base.metadata.create_all(engine)
self.data = [
['birth', 'id', 'name', 'weight'],
[datetime.date(2014, 11, 11), 0, 'Adam', 11.25],
[datetime.date(2014, 11, 12), 1, 'Smith', 12.25]
]
self.results = [
['birth', 'id', 'name', 'weight'],
['2014-11-11', 0, 'Adam', 11.25],
['2014-11-12', 1, 'Smith', 12.25]
]

def test_one_table(self):
mysession = Session()
writer = SQLTableWriter(mysession,
[Pyexcel,self.data[0], None, None],
auto_commit=False)
writer.write_array(self.data[1:])
writer.close()
mysession.close()
mysession2 = Session()
query_sets=mysession2.query(Pyexcel).all()
results = from_query_sets(self.data[0], query_sets)
assert len(query_sets) == 0
mysession2.close()

0 comments on commit 00036fb

Please sign in to comment.