def test_execute_acquire_sample_with_stream_id_new_not_already_acquiring( self, mock, StreamPublisher_mock): self._bdh._semaphore = Mock() self._bdh._semaphore.acquire.return_value = True self._bdh._glet_queue = Mock() attachment = Attachment() attachment.keywords = ['NewDataCheck', 'NotFound'] attachment2 = Attachment() attachment2.keywords = ['NotTheRightKeyword'] self._bdh._find_new_data_check_attachment = Mock() self._bdh._find_new_data_check_attachment.return_value =\ [attachment2, attachment] stream_route = Mock(spec=StreamRoute) stream_route.exchange_point = sentinel.exchange_point stream_route.routing_key = sentinel.routing_key StreamPublisher_mock = MagicMock(spec=StandaloneStreamPublisher) self._bdh.execute_acquire_sample({ 'stream_id': 'test_stream_id', 'stream_route': stream_route }) self._bdh._semaphore.acquire.assert_called_once_with(blocking=False) self._bdh._find_new_data_check_attachment.assert_called_once()
def test_execute_acquire_data_with_stream_id_new_not_already_acquiring(self, mock): self._bdh._semaphore = Mock() self._bdh._semaphore.acquire.return_value = True attachment = Attachment() attachment.keywords = ['NewDataCheck', 'NotFound'] attachment2 = Attachment() attachment2.keywords = ['NotTheRightKeyword'] self._rr_cli.find_objects.return_value = [attachment2, attachment], '' self._bdh._glet_queue = Mock() self._bdh.execute_acquire_data({'stream_id' : 'test_stream_id'}) self._bdh._semaphore.acquire.assert_called_once_with(blocking=False) self._rr_cli.find_objects.assert_called_once()
def test_execute_acquire_data_with_stream_id_new_not_already_acquiring(self, mock): self._bdh._semaphore = Mock() self._bdh._semaphore.acquire.return_value = True self._bdh._glet_queue = Mock() attachment = Attachment() attachment.keywords = ["NewDataCheck", "NotFound"] attachment2 = Attachment() attachment2.keywords = ["NotTheRightKeyword"] self._bdh._find_new_data_check_attachment = Mock() self._bdh._find_new_data_check_attachment.return_value = [attachment2, attachment] self._bdh.execute_acquire_data({"stream_id": "test_stream_id"}) self._bdh._semaphore.acquire.assert_called_once_with(blocking=False) self._bdh._find_new_data_check_attachment.assert_called_once()
def test_execute_acquire_data_with_stream_id_new_not_already_acquiring( self, mock): self._bdh._semaphore = Mock() self._bdh._semaphore.acquire.return_value = True attachment = Attachment() attachment.keywords = ['NewDataCheck', 'NotFound'] attachment2 = Attachment() attachment2.keywords = ['NotTheRightKeyword'] self._rr_cli.find_objects.return_value = [attachment2, attachment], '' self._bdh._glet_queue = Mock() self._bdh.execute_acquire_data({'stream_id': 'test_stream_id'}) self._bdh._semaphore.acquire.assert_called_once_with(blocking=False) self._rr_cli.find_objects.assert_called_once()
def test_execute_acquire_sample_with_stream_id_new_not_already_acquiring(self, mock): self._bdh._semaphore = Mock() self._bdh._semaphore.acquire.return_value = True self._bdh._glet_queue = Mock() attachment = Attachment() attachment.keywords = ['NewDataCheck', 'NotFound'] attachment2 = Attachment() attachment2.keywords = ['NotTheRightKeyword'] self._bdh._find_new_data_check_attachment = Mock() self._bdh._find_new_data_check_attachment.return_value =\ [attachment2, attachment] stream_route = Mock(spec=StreamRoute) stream_route.exchange_point = sentinel.exchange_point stream_route.routing_key = sentinel.routing_key self._bdh.execute_acquire_sample({'stream_id': 'test_stream_id', 'stream_route': stream_route}) self._bdh._semaphore.acquire.assert_called_once_with(blocking=False) self._bdh._find_new_data_check_attachment.assert_called_once()
def test_execute_acquire_sample_with_stream_id_new_not_already_acquiring(self, mock, StreamPublisher_mock): self._bdh._semaphore = Mock() self._bdh._semaphore.acquire.return_value = True self._bdh._glet_queue = Mock() attachment = Attachment() attachment.keywords = ["NewDataCheck", "NotFound"] attachment2 = Attachment() attachment2.keywords = ["NotTheRightKeyword"] self._bdh._find_new_data_check_attachment = Mock() self._bdh._find_new_data_check_attachment.return_value = [attachment2, attachment] stream_route = Mock(spec=StreamRoute) stream_route.exchange_point = sentinel.exchange_point stream_route.routing_key = sentinel.routing_key StreamPublisher_mock = MagicMock(spec=StandaloneStreamPublisher) self._bdh.execute_acquire_sample({"stream_id": "test_stream_id", "stream_route": stream_route}) self._bdh._semaphore.acquire.assert_called_once_with(blocking=False) self._bdh._find_new_data_check_attachment.assert_called_once()