示例#1
0
 def by_created_at(cls, from_date, to_date=None):
     """Creates and returns an from_date-to_date Filter or from_date Filter for the created_at field
     :param int from_date: the from_date to filter by
     :param int to_date:the to_date to filter by
     :return: Filter object
     """
     return Filter('created_at', values=(from_date, to_date), operator=Filter.OPERATOR['INTERVAL'])
示例#2
0
    def test_equals(self):
        f1 = Filter('a', values=('1', ), operator=Filter.OPERATOR['EQUAL'])
        other_key = Filter('b',
                           values=('2', ),
                           operator=Filter.OPERATOR['EQUAL'])
        eq = Filter('a', values=('1', ), operator=Filter.OPERATOR['EQUAL'])
        other_value = Filter('a',
                             values=('2', ),
                             operator=Filter.OPERATOR['EQUAL'])
        other_op = Filter('a',
                          values=('2', ),
                          operator=Filter.OPERATOR['GREATER_THAN'])

        self.assertEqual(f1, eq)
        self.assertNotEqual(f1, other_key)
        self.assertNotEqual(f1, other_value)
        self.assertNotEqual(f1, other_op)
示例#3
0
 def test_filter_interval_to_dict(self):
     f = Filter('test_interval',
                values=(
                    '123456789',
                    '98717171',
                ),
                operator=Filter.OPERATOR['INTERVAL'])
     self.assertEqual(dict(test_interval='123456789-98717171'), f.to_dict())
示例#4
0
文件: offer.py 项目: cruncher/pymill
 def by_trial_period_days(cls, trial_period_days):
     """Creates and returns an trial_period_days Filter
     :param int trial_period_days: the trial_period_days to filter by
     :return: Filter object
     """
     return Filter('trial_period_days',
                   values=(trial_period_days, ),
                   operator=Filter.OPERATOR['EQUAL'])
示例#5
0
 def by_payment_id(cls, payment_id):
     """Creates and returns an payment Filter
     :param int payment_id: payment id to filter by
     :return: Filter object
     """
     return Filter('transaction',
                   values=(payment_id, ),
                   operator=Filter.OPERATOR['EQUAL'])
示例#6
0
 def by_client_id(cls, client_id):
     """Creates and returns an client Filter
     :param str client_id: the client id to filter by
     :return: Filter object
     """
     return Filter('client',
                   values=(client_id, ),
                   operator=Filter.OPERATOR['EQUAL'])
示例#7
0
 def by_type(cls, typ='creditcard'):
     """Creates and returns an from_date-to_date Filter or from_date Filter for the updated_at field
     :param str typ: creditcard or debit
     :return: Filter object
     """
     return Filter('type',
                   values=(typ, ),
                   operator=Filter.OPERATOR['EQUAL'])
示例#8
0
 def by_description(cls, description):
     """Creates and returns an description Filter
     :param str description: the description to filter by
     :return: Filter object
     """
     return Filter('description',
                   values=(description, ),
                   operator=Filter.OPERATOR['EQUAL'])
示例#9
0
 def by_status(cls, status):
     """Creates and returns a status Filter
     :param str status: the status to filter by
     :return: Filter object
     """
     return Filter('status',
                   values=(status, ),
                   operator=Filter.OPERATOR['EQUAL'])
示例#10
0
 def by_amount(cls, amount):
     """Creates and returns an amount Filter
     :param int amount: the amount to filter by
     :return: Filter object
     """
     return Filter('amount',
                   values=(amount, ),
                   operator=Filter.OPERATOR['EQUAL'])
示例#11
0
 def by_amount_less_than(cls, amount):
     """Creates and returns a less than amount Filter
     :param int amount: the amount to filter by
     :return: Filter object
     """
     return Filter('amount',
                   values=(amount, ),
                   operator=Filter.OPERATOR['LESS_THAN'])
示例#12
0
文件: offer.py 项目: cruncher/pymill
 def by_name(cls, name):
     """Creates and returns an name Filter
     :param str name: the payment id to filter by
     :return: Filter object
     """
     return Filter('name',
                   values=(name, ),
                   operator=Filter.OPERATOR['EQUAL'])
示例#13
0
 def by_card_type(cls, card_type):
     """Creates and returns an card_type Filter
     :param str card_type: the card type to filter by
     :return: Filter object
     """
     return Filter('card_type',
                   values=(card_type, ),
                   operator=Filter.OPERATOR['EQUAL'])
示例#14
0
 def by_url(cls, url):
     """Creates and returns an url Filter
     :param int url: the url to filter by
     :return: Filter object
     """
     return Filter('url',
                   values=(url, ),
                   operator=Filter.OPERATOR['EQUAL'])
示例#15
0
 def by_email(cls, email):
     """Creates and returns an email Filter
     :param str email: the email to filter by
     :return: Filter object
     """
     return Filter('email',
                   values=(email, ),
                   operator=Filter.OPERATOR['EQUAL'])
示例#16
0
 def test_filter_init(self):
     f = Filter('test',
                values=('test_id', 'test_id'),
                operator=Filter.OPERATOR['INTERVAL'])
     self.assertIsInstance(f, Filter)
示例#17
0
 def test_filter_list(self):
     f1 = Filter('a', values=('1', ), operator=Filter.OPERATOR['EQUAL'])
     f2 = Filter('b', values=('2', ), operator=Filter.OPERATOR['EQUAL'])
     combined = FilterList(f1, f2)
     self.assertEqual(dict(a='1', b='2'), combined.to_dict())
示例#18
0
 def test_wrong_operator(self):
     with self.assertRaises(Filter.IllegalOperator):
         Filter('a', values=('1', ), operator='asdf')
示例#19
0
 def by_transaction_id(cls, transaction_id):
     """Creates and returns an transaction Filter
     :param int transaction_id: transaction id to filter by
     :return: Filter object
     """
     return Filter('transaction', values=(transaction_id,), operator=Filter.OPERATOR['EQUAL'])
示例#20
0
 def setUp(self):
     self.filter = Filter('payment',
                          values=('pay_2f82a672574647cd911d', ),
                          operator=Filter.OPERATOR['EQUAL'])