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

Failing test and fix for running take_over twice. #1883

Merged
merged 3 commits into from
Jan 15, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions branch.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
DELETE FROM participants WHERE username = ANY( ARRAY[
'4c46cc22afdd',
'82b0d81fe9e8',
'6b6527ac6c02',
'cbde8c31c11c',
'bcfc65158eaf',
'31d54a0c19ae',
'afbddadaac3c',
'a78c4e42bb93',
'42eb93b3ab89',
'b1bc5e47fe8e',
'3ac515cc8da6',
'14a79340c40d',
'14d60c6884e7',
'0c783dee50ed',
'e2020536ef6d',
'60a5099d49c7',
'64f4f959b322',
'0bdf90d51786',
'880ac6873f7f']);
24 changes: 1 addition & 23 deletions gittip/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,29 +108,7 @@ def _check_orphans(self):
where not exists (select * from elsewhere where elsewhere.participant=username)
and not exists (select * from absorptions where archived_as=username)
""")
known = set((
"4c46cc22afdd",
"82b0d81fe9e8",
"6b6527ac6c02",
"cbde8c31c11c",
"bcfc65158eaf",
"31d54a0c19ae",
"afbddadaac3c",
"a78c4e42bb93",
"42eb93b3ab89",
"b1bc5e47fe8e",
"3ac515cc8da6",
"14a79340c40d",
"14d60c6884e7",
"0c783dee50ed",
"e2020536ef6d",
"60a5099d49c7",
"64f4f959b322",
"0bdf90d51786",
"880ac6873f7f"
))
real = set(orphans) - known
assert len(real) == 0, "missing elsewheres: {}".format(list(real))
assert len(orphans) == 0, "missing elsewheres: {}".format(list(orphans))

def _check_orphans_no_tips(self):
"""
Expand Down
4 changes: 4 additions & 0 deletions gittip/models/_mixin_elsewhere.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@ def take_over(self, account_elsewhere, have_confirmation=False):

other_username = rec.participant

if self.username == other_username:
# this is a no op - trying to take over itself
return


# Make sure we have user confirmation if needed.
# ==============================================
Expand Down
8 changes: 8 additions & 0 deletions tests/test_participant.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ def test_do_not_take_over_zero_tips_receiving(self):
assert 2 == ntips
self.db.self_check()

def test_idempotent(self):
alice = TwitterAccount(self.db, 1, dict(screen_name='alice'))
bob = GitHubAccount(self.db, 2, dict(screen_name='bob'))
alice_participant = alice.opt_in('alice')[0].participant
alice_participant.take_over(bob, have_confirmation=True)
alice_participant.take_over(bob, have_confirmation=True)
self.db.self_check()


class TestParticipant(Harness):
def setUp(self):
Expand Down