Ejemplo n.º 1
0
    def test_facetintervallookup():

        table = (('type', 'start', 'stop', 'value'),
                 ('apple', 1, 4, 'foo'),
                 ('apple', 3, 7, 'bar'),
                 ('orange', 4, 9, 'baz'))

        lkp = facetintervallookup(table, key='type', start='start', stop='stop')

        actual = lkp['apple'].search(0, 1)
        expect = []
        eq_(expect, actual)

        actual = lkp['apple'].search(1, 2)
        expect = [('apple', 1, 4, 'foo')]
        eq_(expect, actual)

        actual = lkp['apple'].search(2, 4)
        expect = [('apple', 1, 4, 'foo'), ('apple', 3, 7, 'bar')]
        eq_(expect, actual)

        actual = lkp['apple'].search(2, 5)
        expect = [('apple', 1, 4, 'foo'), ('apple', 3, 7, 'bar')]
        eq_(expect, actual)

        actual = lkp['orange'].search(2, 5)
        expect = [('orange', 4, 9, 'baz')]
        eq_(expect, actual)

        actual = lkp['orange'].search(9, 14)
        expect = []
        eq_(expect, actual)

        actual = lkp['orange'].search(19, 140)
        expect = []
        eq_(expect, actual)

        actual = lkp['apple'].search(0)
        expect = []
        eq_(expect, actual)

        actual = lkp['apple'].search(1)
        expect = [('apple', 1, 4, 'foo')]
        eq_(expect, actual)

        actual = lkp['apple'].search(2)
        expect = [('apple', 1, 4, 'foo')]
        eq_(expect, actual)

        actual = lkp['apple'].search(4)
        expect = [('apple', 3, 7, 'bar')]
        eq_(expect, actual)

        actual = lkp['apple'].search(5)
        expect = [('apple', 3, 7, 'bar')]
        eq_(expect, actual)

        actual = lkp['orange'].search(5)
        expect = [('orange', 4, 9, 'baz')]
        eq_(expect, actual)
Ejemplo n.º 2
0
    def test_facetintervallookup_compound():

        table = (('type', 'variety', 'start', 'stop', 'value'),
                 ('apple', 'cox', 1, 4, 'foo'),
                 ('apple', 'fuji', 3, 7, 'bar'),
                 ('orange', 'mandarin', 4, 9, 'baz'))

        lkp = facetintervallookup(table, key=('type', 'variety'), start='start',
                                  stop='stop')

        actual = lkp['apple', 'cox'].search(1, 2)
        expect = [('apple', 'cox', 1, 4, 'foo')]
        eq_(expect, actual)

        actual = lkp['apple', 'cox'].search(2, 4)
        expect = [('apple', 'cox', 1, 4, 'foo')]
        eq_(expect, actual)
Ejemplo n.º 3
0
    def test_facetintervallookup_compound():

        table = (('type', 'variety', 'start', 'stop', 'value'),
                 ('apple', 'cox', 1, 4, 'foo'), ('apple', 'fuji', 3, 7, 'bar'),
                 ('orange', 'mandarin', 4, 9, 'baz'))

        lkp = facetintervallookup(table,
                                  key=('type', 'variety'),
                                  start='start',
                                  stop='stop')

        actual = lkp['apple', 'cox'].search(1, 2)
        expect = [('apple', 'cox', 1, 4, 'foo')]
        eq_(expect, actual)

        actual = lkp['apple', 'cox'].search(2, 4)
        expect = [('apple', 'cox', 1, 4, 'foo')]
        eq_(expect, actual)
Ejemplo n.º 4
0
    def test_facetintervallookup():

        table = (('type', 'start', 'stop', 'value'), ('apple', 1, 4, 'foo'),
                 ('apple', 3, 7, 'bar'), ('orange', 4, 9, 'baz'))

        lkp = facetintervallookup(table,
                                  key='type',
                                  start='start',
                                  stop='stop')

        actual = lkp['apple'].search(0, 1)
        expect = []
        eq_(expect, actual)

        actual = lkp['apple'].search(1, 2)
        expect = [('apple', 1, 4, 'foo')]
        eq_(expect, actual)

        actual = lkp['apple'].search(2, 4)
        expect = [('apple', 1, 4, 'foo'), ('apple', 3, 7, 'bar')]
        eq_(expect, actual)

        actual = lkp['apple'].search(2, 5)
        expect = [('apple', 1, 4, 'foo'), ('apple', 3, 7, 'bar')]
        eq_(expect, actual)

        actual = lkp['orange'].search(2, 5)
        expect = [('orange', 4, 9, 'baz')]
        eq_(expect, actual)

        actual = lkp['orange'].search(9, 14)
        expect = []
        eq_(expect, actual)

        actual = lkp['orange'].search(19, 140)
        expect = []
        eq_(expect, actual)

        actual = lkp['apple'].search(0)
        expect = []
        eq_(expect, actual)

        actual = lkp['apple'].search(1)
        expect = [('apple', 1, 4, 'foo')]
        eq_(expect, actual)

        actual = lkp['apple'].search(2)
        expect = [('apple', 1, 4, 'foo')]
        eq_(expect, actual)

        actual = lkp['apple'].search(4)
        expect = [('apple', 3, 7, 'bar')]
        eq_(expect, actual)

        actual = lkp['apple'].search(5)
        expect = [('apple', 3, 7, 'bar')]
        eq_(expect, actual)

        actual = lkp['orange'].search(5)
        expect = [('orange', 4, 9, 'baz')]
        eq_(expect, actual)