Beispiel #1
0
 def find_all_affiliate_approvals(self,
                                  sort=(),
                                  limit=None,
                                  page=None,
                                  fields=None,
                                  **kwargs):
     return self._call('findAllAffiliateApprovals',
                       sort=sort,
                       limit=limit,
                       page=page,
                       fields=fields,
                       single_result=False,
                       target_class='AffiliateOffer',
                       filters=Filter(**kwargs))
Beispiel #2
0
 def find_all(self,
              sort=(),
              limit=None,
              page=None,
              fields=None,
              contain=None,
              **kwargs):
     assert limit is None or isinstance(limit,
                                        int), 'Limit should be an integer'
     assert page is None or isinstance(page,
                                       int), 'Page should be an integer'
     assert fields is None or isinstance(
         fields, (tuple, list)), 'Fields should be a tuple or list'
     return self._call('findAllInvoices',
                       filters=Filter(**kwargs),
                       sort=Sort(sort, self.model.__name__),
                       limit=limit,
                       page=page,
                       fields=fields,
                       contain=contain,
                       single_result=False)
Beispiel #3
0
 def find_all_advertiser_tag_relations(self, **kwargs):
     return self._call('findAllAdvertiserTagRelations',
                       target_class='TagRelation',
                       single_result=False,
                       filters=Filter(**kwargs))
Beispiel #4
0
import pytest

from pyoffers.utils import Filter, Sort, expand


@pytest.mark.parametrize(
    "value, expected",
    (
        ((1, "key"), {("key", 1)}),
        (([1, 2, 3], "key"), {("key[]", 1), ("key[]", 2), ("key[]", 3)}),
        (({
            "a": 1,
            "b": 2
        }, "key"), {("key[a]", 1), ("key[b]", 2)}),
        (
            (Filter(status=("active", "paused"), currency="USD"), "filters"),
            {("filters[status][]", "active"), ("filters[status][]", "paused"),
             ("filters[currency]", "USD")},
        ),
        ((Filter(id__lt=25), "filters"), {("filters[id][LESS_THAN]", 25)}),
        (
            (Filter(status="active", currency="USD",
                    connector="OR"), "filters"),
            {("filters[OR][status]", "active"),
             ("filters[OR][currency]", "USD")},
        ),
        ((Sort("-key", "Offer"), "sort"), {("sort[Offer.key]", "desc")}),
        ((Sort(["-key1", "key2"],
               "Offer"), "sort"), {("sort[Offer.key1]", "desc"),
                                   ("sort[Offer.key2]", "asc")}),
    ),
Beispiel #5
0
# coding: utf-8
import pytest

from pyoffers.utils import Filter, Sort, expand


@pytest.mark.parametrize('value, expected', (
    ((1, 'key'), {('key', 1)}),
    (([1, 2, 3], 'key'), {('key[]', 1), ('key[]', 2), ('key[]', 3)}),
    (({
        'a': 1,
        'b': 2
    }, 'key'), {('key[a]', 1), ('key[b]', 2)}),
    ((Filter(status=('active', 'paused'),
             currency='USD'), 'filters'), {('filters[status][]', 'active'),
                                           ('filters[status][]', 'paused'),
                                           ('filters[currency]', 'USD')}),
    ((Filter(id__lt=25), 'filters'), {('filters[id][LESS_THAN]', 25)}),
    ((Filter(status='active', currency='USD', connector='OR'), 'filters'), {
        ('filters[OR][status]', 'active'), ('filters[OR][currency]', 'USD')
    }),
    ((Sort('-key', 'Offer'), 'sort'), {('sort[Offer.key]', 'desc')}),
    ((Sort(['-key1', 'key2'], 'Offer'), 'sort'), {('sort[Offer.key1]', 'desc'),
                                                  ('sort[Offer.key2]', 'asc')
                                                  }),
))
def test_expand(value, expected):
    assert set(expand(*value)) == expected
Beispiel #6
0
 def find_all_affiliate_tag_relations(self, **kwargs):
     return self._call("findAllAffiliateTagRelations",
                       target_class="TagRelation",
                       single_result=False,
                       filters=Filter(**kwargs))