def test_s3_events_bucket(self): Config.set_config(BucketConfig.NORMAL) self.assertEqual(Config.get_flashflood_bucket(), os.environ["DSS_FLASHFLOOD_BUCKET"]) Config.set_config(BucketConfig.TEST) self.assertEqual(Config.get_flashflood_bucket(), os.environ["DSS_S3_BUCKET_TEST"]) Config.set_config(BucketConfig.TEST_FIXTURE) self.assertEqual(Config.get_flashflood_bucket(), os.environ["DSS_S3_BUCKET_TEST"])
def _test_delete_event_for_bundle(self, replica, prefixes, key): ff = mock.MagicMock() with mock.patch("dss.events.Config.get_flashflood_handle", return_value=ff): events.delete_event_for_bundle(replica, key, prefixes) used_prefixes = prefixes or replica.flashflood_prefix_write self.assertEqual(len(used_prefixes), ff.delete_event.call_count) for args, pfx in zip(ff.call_args_list, used_prefixes): expected = ((resources.s3, Config.get_flashflood_bucket(), pfx),) self.assertEqual(args, expected)
def _test_record_event_for_bundle(self, replica, prefixes, metadata_document, key): with mock.patch("dss.events.build_bundle_metadata_document", return_value=metadata_document): ff = mock.MagicMock() ff.event_exists = mock.MagicMock(return_value=False) with mock.patch("dss.events.Config.get_flashflood_handle", return_value=ff): ret = events.record_event_for_bundle(replica, key, prefixes) used_prefixes = prefixes or replica.flashflood_prefix_write self.assertEqual(len(used_prefixes), ff.put.call_count) self.assertEqual(metadata_document, ret) for args, pfx in zip(ff.call_args_list, used_prefixes): expected = ((resources.s3, Config.get_flashflood_bucket(), pfx),) self.assertEqual(args, expected)
def destroy(argv: typing.List[str], args: argparse.Namespace): """ Delete all events recorded or journaled into `prefix` """ if "yes" == input(f"Are you sure you want to delete all events for {args.prefix}? Enter 'yes' to continue: "): FlashFlood(resources.s3, Config.get_flashflood_bucket(), args.prefix)._destroy()
def list_journals(argv: typing.List[str], args: argparse.Namespace): ff = FlashFlood(resources.s3, Config.get_flashflood_bucket(), args.prefix) for journal_id in ff.list_journals(): print(journal_id)