Exemple #1
0
    def test_lookup_apply_result_selector_default(self):
        k_v = [('a', 'artichoke'), ('b', 'blackberry'), ('c', 'clementine'),
               ('b', 'blueberry'), ('c', 'cranberry'), ('c', 'cantaloupe')]

        lookup = Lookup(k_v)
        result = lookup.apply_result_selector().to_list()
        # Rely on the fact that the Lookup is ordered by first key insertion
        self.assertEqual(result[0], lookup['a'])
        self.assertEqual(result[1], lookup['b'])
        self.assertEqual(result[2], lookup['c'])
Exemple #2
0
    def test_lookup_apply_result_selector(self):
        k_v = [('a', 'artichoke'), ('b', 'blackberry'), ('c', 'clementine'),
               ('b', 'blueberry'), ('c', 'cranberry'), ('c', 'cantaloupe')]

        lookup = Lookup(k_v)
        result = lookup.apply_result_selector(lambda key, seq: key).to_list()
        self.assertEqual(len(result), 3)
        self.assertTrue('a' in result)
        self.assertTrue('b' in result)
        self.assertTrue('c' in result)
Exemple #3
0
    def test_lookup_is_ordered(self):
        k_v = [ ('a', 'artichoke'),
                ('b', 'blackberry'),
                ('c', 'clementine'),
                ('b', 'blueberry'),
                ('c', 'cranberry'),
                ('c', 'cantaloupe') ]

        lookup = Lookup(k_v)
        result = lookup.apply_result_selector().to_list()
        # Rely on the fact that the Lookup is ordered by first key insertion
        self.assertEqual(list(result[0]), ['artichoke'])
        self.assertEqual(list(result[1]), ['blackberry', 'blueberry'])
        self.assertEqual(list(result[2]), ['clementine', 'cranberry', 'cantaloupe'])
Exemple #4
0
    def test_lookup_apply_result_selector(self):
        k_v = [ ('a', 'artichoke'),
                ('b', 'blackberry'),
                ('c', 'clementine'),
                ('b', 'blueberry'),
                ('c', 'cranberry'),
                ('c', 'cantaloupe') ]

        lookup = Lookup(k_v)
        result = lookup.apply_result_selector(lambda key, seq: key).to_list()
        self.assertEqual(len(result), 3)
        self.assertTrue('a' in result)
        self.assertTrue('b' in result)
        self.assertTrue('c' in result)
    def test_lookup_is_ordered(self):
        k_v = [
            ("a", "artichoke"),
            ("b", "blackberry"),
            ("c", "clementine"),
            ("b", "blueberry"),
            ("c", "cranberry"),
            ("c", "cantaloupe"),
        ]

        lookup = Lookup(k_v)
        result = lookup.apply_result_selector().to_list()
        # Rely on the fact that the Lookup is ordered by first key insertion
        self.assertEqual(list(result[0]), ["artichoke"])
        self.assertEqual(list(result[1]), ["blackberry", "blueberry"])
        self.assertEqual(list(result[2]), ["clementine", "cranberry", "cantaloupe"])
    def test_lookup_apply_result_selector(self):
        k_v = [
            ("a", "artichoke"),
            ("b", "blackberry"),
            ("c", "clementine"),
            ("b", "blueberry"),
            ("c", "cranberry"),
            ("c", "cantaloupe"),
        ]

        lookup = Lookup(k_v)
        result = lookup.apply_result_selector(lambda key, seq: key).to_list()
        self.assertEqual(len(result), 3)
        self.assertTrue("a" in result)
        self.assertTrue("b" in result)
        self.assertTrue("c" in result)