Пример #1
0
    def test__poll(self, time_mock):
        stream_route = Mock(spec=StreamRoute)
        dh_config = {
            'external_dataset_res_id': 'external_ds',
            'stream_id': 'test_stream_id',
            'stream_route': stream_route
        }

        bdh = BaseDataHandler(dh_config)
        execute_acquire_sample_mock = MagicMock()
        bdh.execute_acquire_sample = execute_acquire_sample_mock

        bdh._params = {'POLLING_INTERVAL': 1}
        glet = spawn(bdh._poll)

        self.counter = 0

        def inc_counter(*args):
            self.counter += 1
            if self.counter == 2:
                bdh._polling = False

        time_mock.sleep.side_effect = inc_counter

        glet.join(timeout=5)
        self.assertTrue(execute_acquire_sample_mock.call_count >= 1)
    def test__poll(self, time_mock):
        stream_route = Mock(spec=StreamRoute)
        dh_config = {
            'external_dataset_res_id': 'external_ds',
            'stream_id': 'test_stream_id',
            'stream_route': stream_route
        }

        bdh = BaseDataHandler(dh_config)
        execute_acquire_sample_mock = MagicMock()
        bdh.execute_acquire_sample = execute_acquire_sample_mock

        bdh._params = {'POLLING_INTERVAL': 1}
        glet = spawn(bdh._poll)

        self.counter = 0

        def inc_counter(*args):
            self.counter += 1
            if self.counter == 2:
                bdh._polling = False

        time_mock.sleep.side_effect = inc_counter

        glet.join(timeout=5)
        self.assertTrue(execute_acquire_sample_mock.call_count >= 1)
    def test__poll(self, time_mock, execute_acquire_data_mock):
        bdh=BaseDataHandler(None, None, None)
        bdh._params = {'POLLING_INTERVAL':1}
        glet = spawn(bdh._poll)

        self.counter = 0
        def inc_counter(*args):
            self.counter += 1
            if self.counter == 2:
                bdh._polling = False

        time_mock.sleep.side_effect = inc_counter

        glet.join(timeout=5)

        self.assertTrue(execute_acquire_data_mock.call_count >= 2)
    def test__poll(self, time_mock, execute_acquire_data_mock):
        bdh = BaseDataHandler(None, None, None)
        bdh._params = {'POLLING_INTERVAL': 1}
        glet = spawn(bdh._poll)

        self.counter = 0

        def inc_counter(*args):
            self.counter += 1
            if self.counter == 2:
                bdh._polling = False

        time_mock.sleep.side_effect = inc_counter

        glet.join(timeout=5)

        self.assertTrue(execute_acquire_data_mock.call_count >= 2)
    def test__poll(self, time_mock, execute_acquire_data_mock):
        self._stream_registrar = Mock()
        dh_config = {"external_dataset_res_id": "external_ds"}
        bdh = BaseDataHandler(self._stream_registrar, dh_config)
        bdh._params = {"POLLING_INTERVAL": 1}
        glet = spawn(bdh._poll)

        self.counter = 0

        def inc_counter(*args):
            self.counter += 1
            if self.counter == 2:
                bdh._polling = False

        time_mock.sleep.side_effect = inc_counter

        glet.join(timeout=5)

        self.assertTrue(execute_acquire_data_mock.call_count >= 1)