def test_HtmlSiteStore_filesystem_backend(tmp_path_factory): path = str(tmp_path_factory.mktemp('test_HtmlSiteStore_with_TupleFileSystemStoreBackend__dir')) my_store = HtmlSiteStore( store_backend={ "class_name": "TupleFilesystemStoreBackend", "base_directory": "my_store" }, runtime_environment={ "root_directory": path } ) with pytest.raises(TypeError): my_store.get("not_a_ValidationResultIdentifier") with pytest.raises(ValidationError): my_store.get(validationResultIdentifierSchema.load({}).data) ns_1 = SiteSectionIdentifier( site_section_name="validations", resource_identifier=ValidationResultIdentifier.from_tuple(('a', 'b', 'c', 'quarantine', 'prod-100')) ) my_store.set(ns_1, "aaa") # assert my_store.get(ns_1) == "aaa" ns_2 = SiteSectionIdentifier( site_section_name="validations", resource_identifier=ValidationResultIdentifier.from_tuple(('a', 'b', 'c', 'quarantine', 'prod-20')) ) my_store.set(ns_2, "bbb") # assert my_store.get(ns_2) == {"B": "bbb"} print(my_store.list_keys()) # WARNING: OBSERVE THAT SITE_SECTION_NAME IS LOST IN THE CALL TO LIST_KEYS assert set(my_store.list_keys()) == { ns_1.resource_identifier, ns_2.resource_identifier, } print(gen_directory_tree_str(path)) assert gen_directory_tree_str(path) == """\
def test_HtmlSiteStore_filesystem_backend(tmp_path_factory): path = str( tmp_path_factory.mktemp( "test_HtmlSiteStore_with_TupleFileSystemStoreBackend__dir")) my_store = HtmlSiteStore( store_backend={ "class_name": "TupleFilesystemStoreBackend", "base_directory": "my_store", }, runtime_environment={"root_directory": path}, ) with pytest.raises(TypeError): my_store.get("not_a_ValidationResultIdentifier") with pytest.raises(ValidationError): my_store.get(validationResultIdentifierSchema.load({})) ns_1 = SiteSectionIdentifier( site_section_name="validations", resource_identifier=ValidationResultIdentifier.from_tuple(( "a", "b", "c", "quarantine", datetime.datetime.now(datetime.timezone.utc), "prod-100", )), ) my_store.set(ns_1, "aaa") # assert my_store.get(ns_1) == "aaa" ns_2 = SiteSectionIdentifier( site_section_name="validations", resource_identifier=ValidationResultIdentifier.from_tuple(( "a", "b", "c", "quarantine", datetime.datetime.now(datetime.timezone.utc), "prod-20", )), ) my_store.set(ns_2, "bbb") # assert my_store.get(ns_2) == {"B": "bbb"} print(my_store.list_keys()) # WARNING: OBSERVE THAT SITE_SECTION_NAME IS LOST IN THE CALL TO LIST_KEYS assert set(my_store.list_keys()) == { ns_1.resource_identifier, ns_2.resource_identifier, } print(gen_directory_tree_str(path)) assert (gen_directory_tree_str(path) == """\ test_HtmlSiteStore_with_TupleFileSystemStoreBackend__dir0/ my_store/ validations/ a/ b/ c/ quarantine/ 20190926T134241.000000Z/ prod-100.html prod-20.html """)