def test_valid_data_is_deserialized(self): mock_digest = self.mocker.mock() mock_digest(mocker.ANY) self.mocker.result('e5fcf4f4606df6368779205e29b22e5851355de3') self.mocker.replay() in_stream = StringIO(self.serialized_message) messages = utils.recv_messages(in_stream, mock_digest) self.assertEqual(messages.next(), 'message')
def test_corrupted_data_is_bypassed(self): mock_digest = self.mocker.mock() mock_digest(mocker.ANY) self.mocker.result('e5fcf4f4606df6368779205e29b22e5851355de3XXXXX') self.mocker.replay() in_stream = StringIO(self.serialized_message) messages = utils.recv_messages(in_stream, mock_digest) self.assertRaises(StopIteration, lambda: messages.next())
def test_raises_StopIteration_while_the_stream_is_exhausted(self): in_stream = StringIO() messages = utils.recv_messages(in_stream, utils.make_digest) self.assertRaises(StopIteration, lambda: messages.next())
return [ models.Status.error, "Mismatched data: %s. Expected one of %s" % (" | ".join(unmatched), " | ".join(expected)), ] if __name__ == "__main__": # App bootstrapping: # Setting up the app configuration, logging and SqlAlchemy Session. config = utils.balaio_config_from_env() utils.setup_logging() models.Session.configure(bind=models.create_engine_from_config(config)) # Setting up the messaging machinery. input_stream = utils.get_readable_socket(config.get("app", "socket")) messages = utils.recv_messages(input_stream, utils.make_digest) # Setting up some pipe dependencies. scieloapi = scieloapi.Client( config.get("manager", "api_username"), config.get("manager", "api_key"), api_uri=config.get("manager", "api_url"), ) notifier_dep = notifier.validation_notifier_factory(config) Session = models.Session Session.configure(bind=models.create_engine_from_config(config)) ppl = vpipes.Pipeline( SetupPipe(notifier_dep, scieloapi, scieloapitoolbelt, checkin.PackageAnalyzer, utils.is_valid_issn, Session),