Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Fix #413
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed Dec 8, 2012
1 parent b21e3a5 commit b1ebc3d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
8 changes: 6 additions & 2 deletions gittip/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,11 @@ def _diff(self, a, b, compact):
updates = []
deletes = []

for key, row in b_table.items():
# Be sure to sort {a,b}_table.items() so we can depend on the sort
# order of the inserts, updates, and deletes lists.
# See https://github.com/whit537/www.gittip.com/issues/413.

for key, row in sorted(b_table.items()):
if key not in a_table:
inserts.append(row)
else:
Expand All @@ -200,7 +204,7 @@ def _diff(self, a, b, compact):
update[pkey] = row[pkey] # include primary key
updates.append(update)

for key, row in a_table.items():
for key, row in sorted(a_table.items()):
if key not in b_table:
deletes.append(row)

Expand Down
4 changes: 2 additions & 2 deletions tests/test_billing.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,8 @@ def test_payday_moves_money(charge_on_balanced):
tips = testing.setup_tips(('buz', 'bar', '6.00', True)) # under $10!
with testing.load(*tips) as context:
Payday(context.db).run()
expected = [ {"id": "buz", "balance": Decimal('3.32')}
, {"id": "bar", "balance": Decimal('6.00')}
expected = [ {"id": "bar", "balance": Decimal('6.00')}
, {"id": "buz", "balance": Decimal('3.32')}
]
actual = context.diff()['participants']['updates']
assert actual == expected, actual
Expand Down
10 changes: 5 additions & 5 deletions tests/test_is_suspicious.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_participants_start_out_with_is_suspicious_None():
def test_toggling_NULL_gives_true():
with participants() as context:
toggle_is_suspicious()
actual = context.diff()['participants']['updates'][0]['is_suspicious']
actual = context.diff()['participants']['updates'][1]['is_suspicious']
assert actual is True, actual

def test_toggling_changes_two_things():
Expand All @@ -32,22 +32,22 @@ def test_toggling_changes_two_things():
actual = context.diff(compact=True)
assert actual == {'participants': [0,2,0]}, actual

def test_but_the_second_thing_is_just_bars_session():
def test_but_the_first_thing_is_just_bars_session():
with participants() as context:
toggle_is_suspicious()
expected = ('bar', ['id', 'session_expires', 'session_token'])
second = context.diff()['participants']['updates'][1]
second = context.diff()['participants']['updates'][0]
actual = (second['id'], sorted(second.keys()))
assert actual == expected, actual

def test_toggling_true_gives_false():
with participants(True) as context:
toggle_is_suspicious()
actual = context.diff()['participants']['updates'][0]['is_suspicious']
actual = context.diff()['participants']['updates'][1]['is_suspicious']
assert actual is False, actual

def test_toggling_false_gives_true():
with participants(False) as context:
toggle_is_suspicious()
actual = context.diff()['participants']['updates'][0]['is_suspicious']
actual = context.diff()['participants']['updates'][1]['is_suspicious']
assert actual is True, actual

0 comments on commit b1ebc3d

Please sign in to comment.