コード例 #1
0
    def test_delete_and_restore(self):
        with patch('core.models.profile.bankcard.DEBUG', True):
            b1 = BankCard.add(self.local_account.id, '13800138000',
                              '6222980000000002', '1', '440113', '440000',
                              '大望路支行', False)
            assert b1

        BankCard.delete_by_card_number('6222980000000002',
                                       self.local_account.id)
        b2 = BankCard.get(b1.id_)
        assert b2 is None

        BankCard.restore(b1.id_, self.local_account.id)
        b3 = BankCard.get(b1.id_)
        assert b3

        assert b3.mobile_phone == '13800138000'
        assert b3.card_number == '6222980000000002'
        assert b3.city_id == '440113'
        assert b3.province_id == '440000'
        assert b3.local_bank_name == '大望路支行'
コード例 #2
0
ファイル: order.py プロジェクト: c1xfr2e/soledad
 def restore_bankcard(self, force=False):
     if not self.bankcard_id:
         raise ValueError('missing bankcard_id')
     try:
         return BankCard.restore(self.bankcard_id, self.user_id)
     except BankCardChanged as e:
         if force:
             new_bankcard_id = e.args[0]
             self.migrate_bankcard(self.bankcard_id, new_bankcard_id)
             self.bankcard_id = new_bankcard_id
             try:
                 del self.bankcard
             except AttributeError:
                 pass
             return self.bankcard
         else:
             raise