diff --git a/integration_tests.py b/integration_tests.py index f13e09e81..cc9aceaed 100644 --- a/integration_tests.py +++ b/integration_tests.py @@ -15,6 +15,7 @@ import data_access_token import folder +import meta import schema from util import avu, collection, config, constants, data_object, group, log, msi, resource, rule, user @@ -170,6 +171,30 @@ def _test_schema_active_schema_vault_without_research(ctx): return result +def _test_get_latest_vault_metadata_path_empty(ctx): + tmp_collection = _create_tmp_collection(ctx) + latest_file = meta.get_latest_vault_metadata_path(ctx, tmp_collection) + collection.remove(ctx, tmp_collection) + return latest_file is None + + +def _test_get_latest_vault_metadata_path_normal(ctx): + tmp_collection = _create_tmp_collection(ctx) + data_object.write(ctx, os.path.join(tmp_collection, "yoda-metadata[1722869873].json"), "test") + data_object.write(ctx, os.path.join(tmp_collection, "yoda-metadata[1722869875].json"), "test") + data_object.write(ctx, os.path.join(tmp_collection, "yoda-metadata[1722869877].json"), "test") + data_object.write(ctx, os.path.join(tmp_collection, "yoda-metadata[1722869876].json"), "test") + data_object.write(ctx, os.path.join(tmp_collection, "yoda-metadata[1722869874].json"), "test") + latest_file = meta.get_latest_vault_metadata_path(ctx, tmp_collection) + data_object.remove(ctx, os.path.join(tmp_collection, "yoda-metadata[1722869873].json")) + data_object.remove(ctx, os.path.join(tmp_collection, "yoda-metadata[1722869875].json")) + data_object.remove(ctx, os.path.join(tmp_collection, "yoda-metadata[1722869877].json")) + data_object.remove(ctx, os.path.join(tmp_collection, "yoda-metadata[1722869876].json")) + data_object.remove(ctx, os.path.join(tmp_collection, "yoda-metadata[1722869874].json")) + collection.remove(ctx, tmp_collection) + return latest_file == os.path.join(tmp_collection, "yoda-metadata[1722869877].json") + + def _test_folder_secure_func(ctx, func): """Create tmp collection, apply func to it and get result, and clean up. Used for testing functions that modify avu/acls related to folder secure. @@ -405,6 +430,12 @@ def _test_folder_secure_func(ctx, func): {"name": "groups.rule_group_expiration_date_validate.6", "test": lambda ctx: ctx.rule_group_expiration_date_validate("2044-02-26", ""), "check": lambda x: x['arguments'][1] == 'true'}, + {"name": "meta.get_latest_vault_metadata_path.empty", + "test": lambda ctx: _test_get_latest_vault_metadata_path_empty(ctx), + "check": lambda x: x}, + {"name": "meta.get_latest_vault_metadata_path.normal", + "test": lambda ctx: _test_get_latest_vault_metadata_path_normal(ctx), + "check": lambda x: x}, {"name": "policies.check_anonymous_access_allowed.local", "test": lambda ctx: ctx.rule_check_anonymous_access_allowed("127.0.0.1", ""), "check": lambda x: x['arguments'][1] == 'true'},