Esempio n. 1
0
 def testRemoteServiceWithBadCore(self):
     remote = SynchronousRemote(host='localhost',
                                port=self.httpPort,
                                path='/remote')
     self.assertRaises(
         IOError,
         lambda: remote.executeQuery(parseCql('*'), core='doesnotexist'))
    def testDedup(self):
        remote = SynchronousRemote(host='localhost', port=self.httpPort, path='/remote')
        response = remote.executeQuery(cqlAbstractSyntaxTree=parseString('*'), dedupField="__key__.field", core="main", stop=3, sortKeys=[{'sortBy': '__id__', 'sortDescending': False}])
        self.assertEqual(100, response.total)
        self.assertEqual(100, response.totalWithDuplicates)
        self.assertEquals(
            [('record:1', 1), ('record:10', 1), ('record:100', 1)],
            [(hit.id, hit.duplicateCount['__key__.field']) for hit in response.hits]
        )

        response = remote.executeQuery(cqlAbstractSyntaxTree=parseString('*'), dedupField="__key__.groupfield", dedupSortField="__id__", core="main2", stop=3, sortKeys=[{'sortBy': '__id__', 'sortDescending': False}])
        self.assertEqual(10, response.total)
        self.assertEqual(1000, response.totalWithDuplicates)
        self.assertEquals(
            [100] * 3,
            [hit.duplicateCount['__key__.groupfield'] for hit in response.hits]
        )
 def testGrouping(self):
     remote = SynchronousRemote(host='localhost', port=self.httpPort, path='/remote')
     response = remote.executeQuery(cqlAbstractSyntaxTree=parseString('*'), groupingField="__key__.groupfield", core="main2", stop=3, sortKeys=[{'sortBy': '__id__', 'sortDescending': False}])
     self.assertEqual(3, len(response.hits))
     self.assertEquals(
         [('record:1', 100), ('record:100', 100), ('record:200', 100)],
         [(hit.id, len(hit.duplicates['__key__.groupfield'])) for hit in response.hits]
     )
Esempio n. 4
0
    def testDedup(self):
        remote = SynchronousRemote(host='localhost', port=self.httpPort, path='/remote')
        response = remote.executeQuery(cqlAbstractSyntaxTree=parseString('*'), dedupField="__key__.field", core="main", stop=3)
        self.assertEqual(100, response.total)
        self.assertEqual(100, response.totalWithDuplicates)
        self.assertEquals(
            [1, 1, 1],
            [hit.duplicateCount['__key__.field'] for hit in response.hits]
        )

        response = remote.executeQuery(cqlAbstractSyntaxTree=parseString('*'), dedupField="__key__.groupfield", dedupSortField="__id__", core="main2", stop=3)
        self.assertEqual(10, response.total)
        self.assertEqual(1000, response.totalWithDuplicates)
        self.assertEquals(
            [100] * 3,
            [hit.duplicateCount['__key__.groupfield'] for hit in response.hits]
        )
Esempio n. 5
0
    def testDedup(self):
        remote = SynchronousRemote(host='localhost', port=self.httpPort, path='/remote')
        response = remote.executeQuery(cqlAbstractSyntaxTree=parseString('*'), dedupField="__key__.field", core="main", stop=3)
        self.assertEqual(100, response.total)
        self.assertEqual(100, response.totalWithDuplicates)
        self.assertEquals(
            [1, 1, 1],
            [hit.duplicateCount['__key__.field'] for hit in response.hits]
        )

        response = remote.executeQuery(cqlAbstractSyntaxTree=parseString('*'), dedupField="__key__.groupfield", dedupSortField="__id__", core="main2", stop=3)
        self.assertEqual(3, len(response.hits))
        self.assertEqual(10, response.total)
        self.assertEqual(1000, response.totalWithDuplicates)
        self.assertEquals(
            [100] * 3,
            [hit.duplicateCount['__key__.groupfield'] for hit in response.hits]
        )

        response = remote.executeQuery(cqlAbstractSyntaxTree=parseString('*'), dedupField="__key__.groupfield", dedupSortField="__numeric__.sort1", core="main2", stop=100000)
        self.assertEqual(10, len(response.hits))
        self.assertEqual(10, response.total)
        self.assertEqual(1000, response.totalWithDuplicates)
        self.assertEquals(
            [100] * 10,
            [hit.duplicateCount['__key__.groupfield'] for hit in response.hits]
        )

        response = remote.executeQuery(cqlAbstractSyntaxTree=parseString('groupfield=1'), dedupField="__key__.groupfield", dedupSortField=["__numeric__.sort1","__numeric__.sort2"], core="main2", stop=10000)
        self.assertEqual(1, len(response.hits))
        self.assertEqual(1, response.total)
        self.assertEqual(100, response.totalWithDuplicates)
        self.assertEquals(['main2:record:199'], [hit.id for hit in response.hits]
        )

        response = remote.executeQuery(cqlAbstractSyntaxTree=parseString('groupfield=1'), dedupField="__key__.groupfield", dedupSortField=["__numeric__.sort2","__numeric__.sort1"], core="main2", stop=10000)
        self.assertEqual(1, len(response.hits))
        self.assertEqual(1, response.total)
        self.assertEqual(100, response.totalWithDuplicates)
        self.assertEquals(['main2:record:199'], [hit.id for hit in response.hits]
        )
Esempio n. 6
0
    def testDedup(self):
        remote = SynchronousRemote(host='localhost',
                                   port=self.httpPort,
                                   path='/remote')
        response = remote.executeQuery(cqlAbstractSyntaxTree=parseString('*'),
                                       dedupField="__key__.field",
                                       core="main",
                                       stop=3,
                                       sortKeys=[{
                                           'sortBy': '__id__',
                                           'sortDescending': False
                                       }])

        self.assertEquals([('record:1', 0), ('record:10', 1),
                           ('record:100', 1)],
                          [(hit.id, hit.duplicateCount['__key__.field'])
                           for hit in response.hits])
Esempio n. 7
0
 def testRemoteServiceOnBadPath(self):
     remote = SynchronousRemote(host='localhost',
                                port=self.httpPort,
                                path='/does/not/exist')
     self.assertRaises(IOError, lambda: remote.executeQuery(parseCql('*')))
Esempio n. 8
0
 def testRemoteService(self):
     remote = SynchronousRemote(host='localhost',
                                port=self.httpPort,
                                path='/remote')
     response = remote.executeQuery(parseCql('*'))
     self.assertEquals(100, response.total)
 def testRemoteServiceWithBadCore(self):
     remote = SynchronousRemote(host='localhost', port=self.httpPort, path='/remote')
     self.assertRaises(IOError, lambda: remote.executeQuery(cqlToExpression('*'), core='doesnotexist'))
 def testRemoteServiceOnBadPath(self):
     remote = SynchronousRemote(host='localhost', port=self.httpPort, path='/does/not/exist')
     self.assertRaises(IOError, lambda: remote.executeQuery(cqlToExpression('*')))
 def testRemoteService(self):
     remote = SynchronousRemote(host='localhost', port=self.httpPort, path='/remote')
     response = remote.executeQuery(cqlToExpression('*'))
     self.assertEquals(100, response.total)