当前位置: 首页>>代码示例>>Python>>正文


Python Payday.pachinko方法代码示例

本文整理汇总了Python中gittip.billing.payday.Payday.pachinko方法的典型用法代码示例。如果您正苦于以下问题:Python Payday.pachinko方法的具体用法?Python Payday.pachinko怎么用?Python Payday.pachinko使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gittip.billing.payday.Payday的用法示例。


在下文中一共展示了Payday.pachinko方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestPachinko

# 需要导入模块: from gittip.billing.payday import Payday [as 别名]
# 或者: from gittip.billing.payday.Payday import pachinko [as 别名]
class TestPachinko(Harness):

    def setUp(self):
        Harness.setUp(self)
        self.payday = Payday(self.db)

    def test_get_participants_gets_participants(self):
        a_team = self.make_participant('a_team', claimed_time='now', number='plural', balance=20)
        a_team.add_member(self.make_participant('alice', claimed_time='now'))
        a_team.add_member(self.make_participant('bob', claimed_time='now'))

        ts_start = self.payday.start()

        actual = [p.username for p in self.payday.get_participants(ts_start)]
        expected = ['a_team', 'alice', 'bob']
        assert actual == expected

    def test_pachinko_pachinkos(self):
        a_team = self.make_participant('a_team', claimed_time='now', number='plural', balance=20, pending=0)
        a_team.add_member(self.make_participant('alice', claimed_time='now', balance=0, pending=0))
        a_team.add_member(self.make_participant('bob', claimed_time='now', balance=0, pending=0))

        ts_start = self.payday.start()

        participants = self.payday.genparticipants(ts_start, ts_start)
        self.payday.pachinko(ts_start, participants)
开发者ID:JeffSpies,项目名称:www.gittip.com,代码行数:28,代码来源:test_billing_payday.py

示例2: TestPachinko

# 需要导入模块: from gittip.billing.payday import Payday [as 别名]
# 或者: from gittip.billing.payday.Payday import pachinko [as 别名]
class TestPachinko(Harness):

    def setUp(self):
        Harness.setUp(self)
        self.payday = Payday(self.db)

    def test_get_participants_gets_participants(self):
        a_team = self.make_participant('a_team', claimed_time='now', number='plural', balance=20)
        a_team.add_member(self.make_participant('alice', claimed_time='now'))
        a_team.add_member(self.make_participant('bob', claimed_time='now'))

        ts_start = self.payday.start()

        actual = [p.username for p in self.payday.get_participants(ts_start)]
        expected = ['a_team', 'alice', 'bob']
        assert actual == expected

    def test_pachinko_pachinkos(self):
        a_team = self.make_participant('a_team', claimed_time='now', number='plural', balance=20, \
                                                                                         pending=0)
        a_team.add_member(self.make_participant('alice', claimed_time='now', balance=0, pending=0))
        a_team.add_member(self.make_participant('bob', claimed_time='now', balance=0, pending=0))

        ts_start = self.payday.start()

        participants = self.payday.genparticipants(ts_start, LOOP_PACHINKO)
        self.payday.pachinko(ts_start, participants)

        assert Participant.from_username('alice').pending == D('0.01')
        assert Participant.from_username('bob').pending == D('0.01')

    def test_pachinko_sees_current_take(self):
        a_team = self.make_participant('a_team', claimed_time='now', number='plural', balance=20, \
                                                                                         pending=0)
        alice = self.make_participant('alice', claimed_time='now', balance=0, pending=0)
        a_team.add_member(alice)
        a_team.set_take_for(alice, D('1.00'), alice)

        ts_start = self.payday.start()

        participants = self.payday.genparticipants(ts_start, LOOP_PACHINKO)
        self.payday.pachinko(ts_start, participants)

        assert Participant.from_username('alice').pending == D('1.00')

    def test_pachinko_ignores_take_set_after_payday_starts(self):
        a_team = self.make_participant('a_team', claimed_time='now', number='plural', balance=20, \
                                                                                         pending=0)
        alice = self.make_participant('alice', claimed_time='now', balance=0, pending=0)
        a_team.add_member(alice)
        a_team.set_take_for(alice, D('0.33'), alice)

        ts_start = self.payday.start()
        a_team.set_take_for(alice, D('1.00'), alice)

        participants = self.payday.genparticipants(ts_start, LOOP_PACHINKO)
        self.payday.pachinko(ts_start, participants)

        assert Participant.from_username('alice').pending == D('0.33')

    def test_pachinko_ignores_take_thats_already_been_processed(self):
        a_team = self.make_participant('a_team', claimed_time='now', number='plural', balance=20, \
                                                                                         pending=0)
        alice = self.make_participant('alice', claimed_time='now', balance=0, pending=0)
        a_team.add_member(alice)
        a_team.set_take_for(alice, D('0.33'), alice)

        ts_start = self.payday.start()
        a_team.set_take_for(alice, D('1.00'), alice)

        for i in range(4):
            participants = self.payday.genparticipants(ts_start, LOOP_PACHINKO)
            self.payday.pachinko(ts_start, participants)

        assert Participant.from_username('alice').pending == D('0.33')
开发者ID:barmoshe,项目名称:www.gittip.com,代码行数:77,代码来源:test_billing_payday.py

示例3: TestPachinko

# 需要导入模块: from gittip.billing.payday import Payday [as 别名]
# 或者: from gittip.billing.payday.Payday import pachinko [as 别名]
class TestPachinko(Harness):
    def setUp(self):
        Harness.setUp(self)
        self.payday = Payday(self.db)

    def test_get_participants_gets_participants(self):
        a_team = self.make_participant("a_team", claimed_time="now", number="plural", balance=20)
        a_team.add_member(self.make_participant("alice", claimed_time="now"))
        a_team.add_member(self.make_participant("bob", claimed_time="now"))

        ts_start = self.payday.start()

        actual = [p.username for p in self.payday.get_participants(ts_start)]
        expected = ["a_team", "alice", "bob"]
        assert actual == expected

    def test_pachinko_pachinkos(self):
        a_team = self.make_participant("a_team", claimed_time="now", number="plural", balance=20, pending=0)
        a_team.add_member(self.make_participant("alice", claimed_time="now", balance=0, pending=0))
        a_team.add_member(self.make_participant("bob", claimed_time="now", balance=0, pending=0))

        ts_start = self.payday.start()

        participants = self.payday.genparticipants(ts_start, LOOP_PACHINKO)
        self.payday.pachinko(ts_start, participants)

        assert Participant.from_username("alice").pending == D("0.01")
        assert Participant.from_username("bob").pending == D("0.01")

    def test_pachinko_sees_current_take(self):
        a_team = self.make_participant("a_team", claimed_time="now", number="plural", balance=20, pending=0)
        alice = self.make_participant("alice", claimed_time="now", balance=0, pending=0)
        a_team.add_member(alice)
        a_team.set_take_for(alice, D("1.00"), alice)

        ts_start = self.payday.start()

        participants = self.payday.genparticipants(ts_start, LOOP_PACHINKO)
        self.payday.pachinko(ts_start, participants)

        assert Participant.from_username("alice").pending == D("1.00")

    def test_pachinko_ignores_take_set_after_payday_starts(self):
        a_team = self.make_participant("a_team", claimed_time="now", number="plural", balance=20, pending=0)
        alice = self.make_participant("alice", claimed_time="now", balance=0, pending=0)
        a_team.add_member(alice)
        a_team.set_take_for(alice, D("0.33"), alice)

        ts_start = self.payday.start()
        a_team.set_take_for(alice, D("1.00"), alice)

        participants = self.payday.genparticipants(ts_start, LOOP_PACHINKO)
        self.payday.pachinko(ts_start, participants)

        assert Participant.from_username("alice").pending == D("0.33")

    def test_pachinko_ignores_take_thats_already_been_processed(self):
        a_team = self.make_participant("a_team", claimed_time="now", number="plural", balance=20, pending=0)
        alice = self.make_participant("alice", claimed_time="now", balance=0, pending=0)
        a_team.add_member(alice)
        a_team.set_take_for(alice, D("0.33"), alice)

        ts_start = self.payday.start()
        a_team.set_take_for(alice, D("1.00"), alice)

        for i in range(4):
            participants = self.payday.genparticipants(ts_start, LOOP_PACHINKO)
            self.payday.pachinko(ts_start, participants)

        assert Participant.from_username("alice").pending == D("0.33")
开发者ID:joshgillies,项目名称:www.gittip.com,代码行数:72,代码来源:test_billing_payday.py


注:本文中的gittip.billing.payday.Payday.pachinko方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。