Exemple #1
0
 def test_only_keep_last_threshold_upwards_and_flags(self):
     Threshold.objects.create(
         balance=2,
         actions=pickle.dumps(['send_notification']),
         up=True,
         down=False)
     Threshold.objects.create(
         balance=3,
         actions=pickle.dumps(['send_notification']),
         up=True,
         down=False)
     Threshold.objects.create(
         balance=1,
         actions=pickle.dumps(['send_notification']),
         up=True,
         down=False)
     Threshold.objects.create(
         balance=4,
         actions=pickle.dumps(['send_notification']),
         up=False,
         down=True)
     KeystoneClient.get_client().AndReturn(
         get_stub_keystone_client(3))
     ThresholdActionBase.pass_event(
         passed_limit=decimal.Decimal(3),
         project_id=1,
         current_balance=decimal.Decimal(5))
     self.mox.ReplayAll()
     ut = UserTransactions()
     ut.grant_user_promotion(1, 5, 'granting promotion')
Exemple #2
0
 def test_only_keep_last_threshold_downwards(self):
     Threshold.objects.create(balance=-2,
                              actions=pickle.dumps(['send_notification']),
                              up=False,
                              down=True)
     Threshold.objects.create(balance=-3,
                              actions=pickle.dumps(['send_notification']),
                              up=False,
                              down=True)
     Threshold.objects.create(balance=-1,
                              actions=pickle.dumps(['send_notification']),
                              up=False,
                              down=True)
     ThresholdActionBase.pass_event(passed_limit=decimal.Decimal(-3),
                                    project_id=1,
                                    current_balance=decimal.Decimal('-5'))
     self.mox.ReplayAll()
     ut = UserTransactions()
     ut.consume_user_money(1, 5, 'some consumption')
Exemple #3
0
 def test_only_keep_last_threshold_downwards(self):
     Threshold.objects.create(
         balance=-2,
         actions=pickle.dumps(['send_notification']),
         up=False,
         down=True)
     Threshold.objects.create(
         balance=-3,
         actions=pickle.dumps(['send_notification']),
         up=False,
         down=True)
     Threshold.objects.create(
         balance=-1,
         actions=pickle.dumps(['send_notification']),
         up=False,
         down=True)
     ThresholdActionBase.pass_event(
         passed_limit=decimal.Decimal(-3),
         project_id=1,
         current_balance=decimal.Decimal('-5'))
     self.mox.ReplayAll()
     ut = UserTransactions()
     ut.consume_user_money(1, 5, 'some consumption')
Exemple #4
0
 def test_only_keep_last_threshold_upwards_and_flags(self):
     Threshold.objects.create(balance=2,
                              actions=pickle.dumps(['send_notification']),
                              up=True,
                              down=False)
     Threshold.objects.create(balance=3,
                              actions=pickle.dumps(['send_notification']),
                              up=True,
                              down=False)
     Threshold.objects.create(balance=1,
                              actions=pickle.dumps(['send_notification']),
                              up=True,
                              down=False)
     Threshold.objects.create(balance=4,
                              actions=pickle.dumps(['send_notification']),
                              up=False,
                              down=True)
     KeystoneClient.get_client().AndReturn(get_stub_keystone_client(3))
     ThresholdActionBase.pass_event(passed_limit=decimal.Decimal(3),
                                    project_id=1,
                                    current_balance=decimal.Decimal(5))
     self.mox.ReplayAll()
     ut = UserTransactions()
     ut.grant_user_promotion(1, 5, 'granting promotion')