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


Python utils.utcnow函数代码示例

本文整理汇总了Python中aspen.utils.utcnow函数的典型用法代码示例。如果您正苦于以下问题:Python utcnow函数的具体用法?Python utcnow怎么用?Python utcnow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: test_non_post_is_405

 def test_non_post_is_405(self):
     self.make_participant('alice', claimed_time=utcnow(), is_admin=True)
     self.make_participant('bob', claimed_time=utcnow())
     actual = self.client.GxT( '/bob/history/record-an-exchange'
                             , auth_as='alice'
                              ).code
     assert actual == 405
开发者ID:Alive-AttemptTheLifeGangHouse,项目名称:www.gittip.com,代码行数:7,代码来源:test_record_an_exchange.py

示例2: test_withdrawals_work

 def test_withdrawals_work(self):
     self.make_participant("alice", claimed_time=utcnow(), is_admin=True)
     self.make_participant("bob", claimed_time=utcnow(), balance=20)
     self.record_an_exchange("-7", "0", "noted", False)
     expected = Decimal("13.00")
     SQL = "SELECT balance FROM participants WHERE username='bob'"
     actual = self.db.one(SQL)
     assert actual == expected
开发者ID:joeyespo,项目名称:www.gittip.com,代码行数:8,代码来源:test_record_an_exchange.py

示例3: test_route_should_belong_to_user_else_400

    def test_route_should_belong_to_user_else_400(self):
        alice = self.make_participant('alice', claimed_time=utcnow(), is_admin=True)
        self.make_participant('bob', claimed_time=utcnow())
        route = ExchangeRoute.insert(alice, 'paypal', '[email protected]')

        response = self.record_an_exchange({'amount': '10', 'fee': '0', 'route_id': route.id}, False)
        assert response.code == 400
        assert response.body == "Route doesn't exist"
开发者ID:HolaChica,项目名称:gratipay.com,代码行数:8,代码来源:test_record_an_exchange.py

示例4: test_withdrawals_work

 def test_withdrawals_work(self):
     self.make_participant('alice', claimed_time=utcnow(), is_admin=True)
     self.make_participant('bob', claimed_time=utcnow(), balance=20)
     self.record_an_exchange('-7', '0', 'noted', False)
     expected = [{"balance": Decimal('13.00')}]
     SQL = "SELECT balance FROM participants WHERE id='bob'"
     actual = list(gittip.db.fetchall(SQL))
     assert actual == expected, actual
开发者ID:arkidas,项目名称:www.gittip.com,代码行数:8,代码来源:test_record_an_exchange.py

示例5: test_withdrawals_work

 def test_withdrawals_work(self):
     self.make_participant('alice', claimed_time=utcnow(), is_admin=True)
     self.make_participant('bob', claimed_time=utcnow(), balance=20)
     self.record_an_exchange('-7', '0', 'noted', make_participants=False)
     expected = Decimal('13.00')
     SQL = "SELECT balance FROM participants WHERE username='bob'"
     actual = self.db.one(SQL)
     assert actual == expected
开发者ID:SirCmpwn,项目名称:gratipay.com,代码行数:8,代码来源:test_record_an_exchange.py

示例6: setup_tips

def setup_tips(*recs):
    """Setup some participants and tips. recs is a list of:

        ("tipper", "tippee", '2.00', False)
                                       ^
                                       |-- good cc?

    good_cc can be True, False, or None

    """
    tips = []

    _participants = {}

    for rec in recs:
        defaults = good_cc, payin_suspended, claimed = (True, False, True)

        if len(rec) == 3:
            tipper, tippee, amount = rec
        elif len(rec) == 4:
            tipper, tippee, amount, good_cc = rec
            payin_suspended, claimed = (False, True)
        elif len(rec) == 5:
            tipper, tippee, amount, good_cc, payin_suspended = rec
            claimed = True
        elif len(rec) == 6:
            tipper, tippee, amount, good_cc, payin_suspended, claimed = rec

        assert good_cc in (True, False, None), good_cc
        assert payin_suspended in (True, False), payin_suspended
        assert claimed in (True, False), claimed

        _participants[tipper] = (good_cc, payin_suspended, claimed)
        if tippee not in _participants:
            _participants[tippee] = defaults
        now = utcnow()
        tips.append({ "ctime": now
                    , "mtime": now
                    , "tipper": tipper
                    , "tippee": tippee
                    , "amount": Decimal(amount)
                     })

    then = utcnow() - datetime.timedelta(seconds=3600)

    participants = []
    for participant_id, (good_cc, payin_suspended, claimed) in _participants.items():
        rec = {"id": participant_id}
        if good_cc is not None:
            rec["last_bill_result"] = "" if good_cc else "Failure!"
            rec["balanced_account_uri"] = "/v1/blah/blah/" + participant_id
        rec["payin_suspended"] = payin_suspended
        if claimed:
            rec["claimed_time"] = then
        participants.append(rec)

    return ["participants"] + participants + ["tips"] + tips
开发者ID:gvenkataraman,项目名称:www.gittip.com,代码行数:57,代码来源:testing.py

示例7: test_tip

    def test_tip(self, log, transfer):
        self.db.run("""

            UPDATE participants
               SET balance=1
                 , balanced_customer_href=%s
                 , is_suspicious=False
             WHERE username='alice'

        """, (self.BALANCED_CUSTOMER_HREF,))
        amount = D('1.00')
        invalid_amount = D('0.00')
        tip = { 'amount': amount
              , 'tippee': self.alice.username
              , 'claimed_time': utcnow()
               }
        ts_start = utcnow()

        result = self.payday.tip(self.alice, tip, ts_start)
        assert result == 1
        result = transfer.called_with(self.alice.username, tip['tippee'],
                                      tip['amount'])
        assert result

        assert log.called_with('SUCCESS: $1 from mjallday to alice.')

        # XXX: Should these tests be broken down to a separate class with the
        # common setup factored in to a setUp method.

        # XXX: We should have constants to compare the values to
        # invalid amount
        tip['amount'] = invalid_amount
        result = self.payday.tip(self.alice, tip, ts_start)
        assert result == 0

        tip['amount'] = amount

        # XXX: We should have constants to compare the values to
        # not claimed
        tip['claimed_time'] = None
        result = self.payday.tip(self.alice, tip, ts_start)
        assert result == 0

        # XXX: We should have constants to compare the values to
        # claimed after payday
        tip['claimed_time'] = utcnow()
        result = self.payday.tip(self.alice, tip, ts_start)
        assert result == 0

        ts_start = utcnow()

        # XXX: We should have constants to compare the values to
        # transfer failed
        transfer.return_value = False
        result = self.payday.tip(self.alice, tip, ts_start)
        assert result == -1
开发者ID:barmoshe,项目名称:www.gittip.com,代码行数:56,代码来源:test_billing_payday.py

示例8: test_tip

    def test_tip(self, log, transfer):
        self.db.run("""

            UPDATE participants
               SET balance=1
                 , balanced_account_uri=%s
                 , is_suspicious=False
             WHERE username='alice'

        """, (self.BALANCED_ACCOUNT_URI,))
        amount = Decimal('1.00')
        invalid_amount = Decimal('0.00')
        tip = { 'amount': amount
              , 'tippee': self.alice.username
              , 'claimed_time': utcnow()
               }
        ts_start = utcnow()

        result = self.payday.tip(self.alice, tip, ts_start)
        assert_equals(result, 1)
        result = transfer.called_with(self.alice.username, tip['tippee'],
                                      tip['amount'])
        self.assertTrue(result)

        self.assertTrue(log.called_with('SUCCESS: $1 from mjallday to alice.'))

        # XXX: Should these tests be broken down to a separate class with the
        # common setup factored in to a setUp method.

        # XXX: We should have constants to compare the values to
        # invalid amount
        tip['amount'] = invalid_amount
        result = self.payday.tip(self.alice, tip, ts_start)
        assert_equals(result, 0)

        tip['amount'] = amount

        # XXX: We should have constants to compare the values to
        # not claimed
        tip['claimed_time'] = None
        result = self.payday.tip(self.alice, tip, ts_start)
        assert_equals(result, 0)

        # XXX: We should have constants to compare the values to
        # claimed after payday
        tip['claimed_time'] = utcnow()
        result = self.payday.tip(self.alice, tip, ts_start)
        assert_equals(result, 0)

        ts_start = utcnow()

        # XXX: We should have constants to compare the values to
        # transfer failed
        transfer.return_value = False
        result = self.payday.tip(self.alice, tip, ts_start)
        assert_equals(result, -1)
开发者ID:stedy,项目名称:www.gittip.com,代码行数:56,代码来源:test_billing_payday.py

示例9: test_api_returns_amount_and_totals

    def test_api_returns_amount_and_totals(self):
        "Test that we get correct amounts and totals back on POSTs to subscription.json"

        # First, create some test data
        # We need accounts
        now = utcnow()
        self.make_team("A", is_approved=True)
        self.make_team("B", is_approved=True)
        self.make_participant("alice", claimed_time=now, last_bill_result='')

        # Then, add a $1.50 and $3.00 subscription
        response1 = self.client.POST( "/A/subscription.json"
                                    , {'amount': "1.50"}
                                    , auth_as='alice'
                                     )

        response2 = self.client.POST( "/B/subscription.json"
                                    , {'amount': "3.00"}
                                    , auth_as='alice'
                                     )

        # Confirm we get back the right amounts.
        first_data = json.loads(response1.body)
        second_data = json.loads(response2.body)
        assert first_data['amount'] == "1.50"
        assert first_data['total_giving'] == "1.50"
        assert second_data['amount'] == "3.00"
        assert second_data['total_giving'] == "4.50"
开发者ID:gaurishankarprasad,项目名称:gratipay.com,代码行数:28,代码来源:test_subscription_json.py

示例10: sign_in

 def sign_in(self, cookies):
     """Start a new session for the user.
     """
     token = uuid.uuid4().hex
     expires = utcnow() + SESSION_TIMEOUT
     self.participant.update_session(token, expires)
     set_cookie(cookies, SESSION, token, expires)
开发者ID:HolaChica,项目名称:gratipay.com,代码行数:7,代码来源:user.py

示例11: make_participant

    def make_participant(self, username, **kw):
        # At this point wireup.db() has been called, but not ...
        wireup.username_restrictions(self.client.website)

        participant = Participant.with_random_username()
        participant.change_username(username)

        if 'elsewhere' in kw or 'claimed_time' in kw:
            username = participant.username
            platform = kw.pop('elsewhere', 'github')
            self.seq += 1
            self.db.run("""
                INSERT INTO elsewhere
                            (platform, user_id, user_name, participant)
                     VALUES (%s,%s,%s,%s)
            """, (platform, self.seq, username, username))

        # Update participant
        if kw:
            if kw.get('claimed_time') == 'now':
                kw['claimed_time'] = utcnow()
            cols, vals = zip(*kw.items())
            cols = ', '.join(cols)
            placeholders = ', '.join(['%s']*len(vals))
            participant = self.db.one("""
                UPDATE participants
                   SET ({0}) = ({1})
                 WHERE username=%s
             RETURNING participants.*::participants
            """.format(cols, placeholders), vals+(participant.username,))

        return participant
开发者ID:atunit,项目名称:www.gittip.com,代码行数:32,代码来源:__init__.py

示例12: setUp

 def setUp(self):
     super(Harness, self).setUp()
     now = utcnow()
     for idx, username in enumerate(["alice", "bob", "carl"], start=1):
         self.make_participant(username, claimed_time=now)
         twitter_account = TwitterAccount(idx, {"screen_name": username})
         Participant(username).take_over(twitter_account)
开发者ID:sigmavirus24,项目名称:www.gittip.com,代码行数:7,代码来源:test_participant.py

示例13: test_post_user_is_not_member_or_team_returns_403

    def test_post_user_is_not_member_or_team_returns_403(self):
        client, csrf_token = self.make_client_and_csrf()

        self.make_team_and_participant()
        self.make_participant("bob", claimed_time=utcnow(), number='plural')

        response = client.post('/team/members/alice.json'
            , {
                'take': '0.01'
              , 'csrf_token': csrf_token
            }
            , user='team'
        )

        actual = response.code
        assert actual == 200

        response = client.post('/team/members/bob.json'
            , {
                'take': '0.01'
              , 'csrf_token': csrf_token
            }
            , user='team'
        )

        actual = response.code
        assert actual == 200

        response = client.post('/team/members/alice.json'
            , { 'csrf_token': csrf_token }
            , user='bob'
        )

        actual = response.code
        assert actual == 403
开发者ID:abnor,项目名称:www.gittip.com,代码行数:35,代码来源:test_membername_json.py

示例14: test_joining_and_leaving_community

    def test_joining_and_leaving_community(self):
        self.make_participant("alice", claimed_time=utcnow())

        response = self.client.GET('/for/communities.json', auth_as='alice')
        assert len(json.loads(response.body)['communities']) == 0

        response = self.client.POST( '/for/communities.json'
                                   , {'name': 'Test', 'is_member': 'true'}
                                   , auth_as='alice'
                                    )

        communities = json.loads(response.body)['communities']
        assert len(communities) == 1
        assert communities[0]['name'] == 'Test'
        assert communities[0]['nmembers'] == 1

        response = self.client.POST( '/for/communities.json'
                                   , {'name': 'Test', 'is_member': 'false'}
                                   , auth_as='alice'
                                    )

        response = self.client.GET('/for/communities.json', auth_as='alice')

        assert len(json.loads(response.body)['communities']) == 0

        # Check that the empty community was deleted
        community = Community.from_slug('test')
        assert not community
开发者ID:HolaChica,项目名称:gratipay.com,代码行数:28,代码来源:test_communities_json.py

示例15: test_post_non_team_member_adds_member_returns_403

    def test_post_non_team_member_adds_member_returns_403(self):
        client, csrf_token = self.make_client_and_csrf()

        self.make_team_and_participant()
        self.make_participant("bob", claimed_time=utcnow())

        response = client.post('/team/members/alice.json'
            , {
                'take': '0.01'
              , 'csrf_token': csrf_token
            }
            , user='team'
        )

        actual = response.code
        assert actual == 200, actual

        response = client.post('/team/members/bob.json'
            , {
                'take': '0.01'
              , 'csrf_token': csrf_token
            }
            , user='alice'
        )

        actual = response.code
        assert actual == 403, actual
开发者ID:angleman,项目名称:www.gittip.com,代码行数:27,代码来源:test_membername_json.py


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