Пример #1
0
    def setUp(self):
        self.src_list1 = [{'foo': 1}, {'foo': 2}, {'foo': 3}]
        self.src_list2 = [{'foo': 4}, {'foo': 5}, {'foo': 6}]
        self.ql1 = QueryList(self.src_list1)
        self.ql2 = QueryList(self.src_list2, wrap=False)

        self.combined = self.ql1 + self.ql2
        self.all_wrapped = self.ql1 + QueryList(self.src_list2)
        self.ql_and_list = self.ql1 + self.src_list2
Пример #2
0
class QueryListCheckElementTests(TestCase):
    "QueryList._check_element()"
    def setUp(self):
        self.ql = QueryList()
        self.bd = BetterDict({'id': 1, 'dog': 4})

    def test_returns_true_if_instance_matches_lookup_value_pairs(self):
        self.assertTrue(self.ql._check_element({'id': 1}, self.bd))

    def test_returns_false_if_instance_doesnt_match_lookup_value_pairs(self):
        self.assertFalse(self.ql._check_element({'id': 2}, self.bd))

    def test_handles_multiple_lookup_value_pairs_correctly(self):
        self.assertTrue(self.ql._check_element({'id': 1, 'dog': 4}, self.bd))
Пример #3
0
class QueryListCheckElementTests(TestCase):
    "QueryList._check_element()"
    def setUp(self):
        self.ql = QueryList()
        self.bd = BetterDict({'id': 1, 'dog': 4})

    def test_returns_true_if_instance_matches_lookup_value_pairs(self):
        self.assertTrue(self.ql._check_element({'id': 1}, self.bd))

    def test_returns_false_if_instance_doesnt_match_lookup_value_pairs(self):
        self.assertFalse(self.ql._check_element({'id': 2}, self.bd))

    def test_handles_multiple_lookup_value_pairs_correctly(self):
        self.assertTrue(self.ql._check_element({'id': 1, 'dog': 4}, self.bd))
Пример #4
0
 def customers(self):
     customers = self.client.get_ticket_customers(self.id)
     return QueryList([
         Customer(data=customer)
         for customer in customers.findall('Customer')
     ],
                      wrap=False)
Пример #5
0
class QueryListConverIterableTests(TestCase):
    """QueryList._convert_iterable()"""
    def setUp(self):
        self.iterable = [{'foo': 1}, {'bar': 2}]
        self.ql = QueryList()

    def test_converts_an_iterables_members_to_BetterDicts_by_default(self):
        converted = self.ql._convert_iterable(self.iterable)
        self.assertEqual(converted[0], BetterDict(self.iterable[0]))

    def test_doesnt_convert_passed_iterable_when_wrapper_attr_is_None(self):
        ql = QueryList(wrapper=None)
        self.assertEqual(ql._convert_iterable(self.iterable), self.iterable)
Пример #6
0
class QueryListConverIterableTests(TestCase):
    """QueryList._convert_iterable()"""
    def setUp(self):
        self.iterable = [{'foo': 1}, {'bar': 2}]
        self.ql = QueryList()

    def test_converts_an_iterables_members_to_BetterDicts_by_default(self):
        converted = self.ql._convert_iterable(self.iterable)
        self.assertEqual(converted[0], BetterDict(self.iterable[0]))

    def test_doesnt_convert_passed_iterable_when_wrapper_attr_is_None(self):
        ql = QueryList(wrapper=None)
        self.assertEqual(ql._convert_iterable(self.iterable), self.iterable)
Пример #7
0
 def test_with_wrap_disabled_doesnt_touch_member_objects(self):
     self.assertEqual(QueryList([1, 2, 3], str, False), [1, 2, 3])
Пример #8
0
 def test_converts_src_data_members_to_wrapper_type(self):
     self.assertEqual(QueryList([1, 2, 3], str), ['1', '2', '3'])
Пример #9
0
 def test_sets_src_data_attirbute_to_iterable_passed_to_constructor(self):
     self.assertEqual(QueryList([1, 2], None).src_data, [1, 2])
Пример #10
0
 def setUp(self):
     self.src_list = SITE_LIST
     self.ql = QueryList(SITE_LIST)
Пример #11
0
 def test_doesnt_convert_passed_iterable_when_wrapper_attr_is_None(self):
     ql = QueryList(wrapper=None)
     self.assertEqual(ql._convert_iterable(self.iterable), self.iterable)
Пример #12
0
 def setUp(self):
     self.iterable = [{'foo': 1}, {'bar': 2}]
     self.ql = QueryList()
Пример #13
0
 def contacts(self):
     contacts = self.client.get_customer_contacts(self.id)
     return QueryList(
         [Contact(data=contact) for contact in contacts.findall('Contact')],
         wrap=False)
Пример #14
0
 def actions(self):
     actions = self.client.get_ticket_actions(self.id)
     return QueryList(
         [Action(data=action) for action in actions.findall('Action')],
         wrap=False)
Пример #15
0
 def setUp(self):
     self.iterable = [{'foo': 1}, {'bar': 2}]
     self.ql = QueryList()
Пример #16
0
 def test_doesnt_convert_passed_iterable_when_wrapper_attr_is_None(self):
     ql = QueryList(wrapper=None)
     self.assertEqual(ql._convert_iterable(self.iterable), self.iterable)
Пример #17
0
 def setUp(self):
     self.ql = QueryList()
     self.bd = BetterDict({'id': 1, 'dog': 4})
Пример #18
0
 def setUp(self):
     self.ql = QueryList()
     self.bd = BetterDict({'id': 1, 'dog': 4})
Пример #19
0
 def test_sets_wrapper_attribute_to_value_passed_as_wrapper_to_init(self):
     self.assertEqual(QueryList(wrapper=dict)._wrapper, dict)
Пример #20
0
 def test_sets_wrapper_attribute_to_BetterDict_by_default(self):
     self.assertEqual(QueryList()._wrapper, BetterDict)
Пример #21
0
 def setUp(self):
     self.src_list = [{'foo': 1}, {'foo': 2}, {'foo': 3}]
     self.query_list = QueryList(self.src_list)