Beispiel #1
0
    def test__intEqual(self):
        data = Row(index='modified', operator='_intEqual', values='20')
        parsed = queryparser._intEqual(MockSite(), data)
        expected = {'modified': {'query': 20}}
        self.assertEqual(parsed, expected)

        data = Row(index='modified', operator='_intEqual', values=['20', '21'])
        parsed = queryparser._intEqual(MockSite(), data)
        expected = {'modified': {'query': [20, 21]}}
        self.assertEqual(parsed, expected)
    def test__intEqual(self):
        data = Row(
            index='modified',
            operator='_intEqual',
            values='20'
        )
        parsed = queryparser._intEqual(MockSite(), data)
        expected = {'modified': {'query': 20}}
        self.assertEqual(parsed, expected)

        data = Row(
            index='modified',
            operator='_intEqual',
            values=['20', '21']
        )
        parsed = queryparser._intEqual(MockSite(), data)
        expected = {'modified': {'query': [20, 21]}}
        self.assertEqual(parsed, expected)
Beispiel #3
0
    def test__intEqual(self):
        # bytes
        data = Row(index='modified', operator='_intEqual', values=b'20')
        parsed = queryparser._intEqual(MockSite(), data)
        expected = {'modified': {'query': 20}}
        self.assertEqual(parsed, expected)

        # list of bytes
        data = Row(index='modified',
                   operator='_intEqual',
                   values=[b'20', b'21'])
        parsed = queryparser._intEqual(MockSite(), data)
        expected = {'modified': {'query': [20, 21]}}
        self.assertEqual(parsed, expected)

        # text
        data = Row(index='modified', operator='_intEqual', values=u'20')
        parsed = queryparser._intEqual(MockSite(), data)
        expected = {'modified': {'query': 20}}
        self.assertEqual(parsed, expected)

        # list of texts
        data = Row(index='modified',
                   operator='_intEqual',
                   values=[u'20', u'21'])
        parsed = queryparser._intEqual(MockSite(), data)
        expected = {'modified': {'query': [20, 21]}}
        self.assertEqual(parsed, expected)

        # bad text
        data = Row(index='modified', operator='_intEqual', values='bad')
        parsed = queryparser._intEqual(MockSite(), data)
        expected = {'modified': {'query': None}}
        self.assertEqual(parsed, expected)

        # list of bad text
        data = Row(index='modified',
                   operator='_intEqual',
                   values=[b'bad', 'text', u'values'])
        parsed = queryparser._intEqual(MockSite(), data)
        expected = {'modified': {'query': None}}
        self.assertEqual(parsed, expected)