Skip to content

Commit

Permalink
Add two tests for #17
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed Aug 10, 2013
1 parent edce194 commit 8931b5f
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,17 @@ def test_TooMany_message_is_helpful_for_a_range(self):
"Got 4 rows; expecting between 1 and 3 (inclusive)."


class TestOneRollsBack(WithData):

def test_one_rollsback_on_error(self):
try:
self.db.one("UPDATE foo SET bar='bum' RETURNING *", strict=True)
except TooMany:
pass
actual = self.db.all("SELECT * FROM foo WHERE bar='bum'")
assert actual == []


class TestOne(WithData):

def test_with_strict_True_one_raises_TooFew(self):
Expand Down Expand Up @@ -209,6 +220,16 @@ def test_one_or_zero_raises_TooFew(self):
, "CREATE TABLE foux (baar text)"
)

def test_one_or_zero_rollsback_on_error(self):
try:
self.db.one_or_zero("CREATE TABLE foux (baar text)")
except TooFew:
pass
self.assertRaises( ProgrammingError
, self.db.all
, "SELECT * FROM foux"
)

def test_one_or_zero_returns_None(self):
actual = self.db.one_or_zero("SELECT * FROM foo WHERE bar='blam'")
assert actual is None
Expand Down

0 comments on commit 8931b5f

Please sign in to comment.