Esempio n. 1
0
 def test_set_last_position(self, mock_create_scanner):
     options = dict(apikey='fake', collection_name='collection', project_id='10804')
     hs_reader = HubstorageReader(dict(options=options), meta())
     hs_reader.set_last_position(dict(last_key='resumekey'))
     self.assertEquals([mock.call.set_startafter('resumekey')],
                       mock_create_scanner.return_value.mock_calls)
     self.assertEquals(dict(last_key='resumekey'), hs_reader.last_position)
Esempio n. 2
0
 def test_set_last_position(self, mock_create_scanner):
     options = dict(apikey='fake',
                    collection_name='collection',
                    project_id=10804)
     hs_reader = HubstorageReader(dict(options=options), meta())
     hs_reader.set_last_position(dict(last_key='resumekey'))
     self.assertEquals([mock.call.set_startafter('resumekey')],
                       mock_create_scanner.return_value.mock_calls)
     self.assertEquals(dict(last_key='resumekey'), hs_reader.last_position)
Esempio n. 3
0
    def test_update_last_position_after_getting_batch(self, mock_create_scanner):
        mock_create_scanner.return_value.get_new_batch.side_effect = [
            [{'_key': 'value1'}, {'_key': 'value2'}],
            [{'_key': 'value3'}, {'_key': 'value4'}],
        ]

        options = dict(apikey='fake', collection_name='collection', project_id='10804')
        hs_reader = HubstorageReader(dict(options=options), meta())
        list(hs_reader.get_next_batch())
        self.assertEquals('value2', hs_reader.last_position['last_key'])
        list(hs_reader.get_next_batch())
        self.assertEquals('value4', hs_reader.last_position['last_key'])
Esempio n. 4
0
    def test_update_last_position_after_getting_batch(self,
                                                      mock_create_scanner):
        mock_create_scanner.return_value.get_new_batch.side_effect = [
            [{
                '_key': 'value1'
            }, {
                '_key': 'value2'
            }],
            [{
                '_key': 'value3'
            }, {
                '_key': 'value4'
            }],
        ]

        options = dict(apikey='fake',
                       collection_name='collection',
                       project_id='10804')
        hs_reader = HubstorageReader(dict(options=options), meta())
        list(hs_reader.get_next_batch())
        self.assertEquals('value2', hs_reader.last_position['last_key'])
        list(hs_reader.get_next_batch())
        self.assertEquals('value4', hs_reader.last_position['last_key'])