def test_does_path_match_base(self): """Tests the does_path_match_base function.""" # as_base(base) canonicalizations: # 1) Not a file path, but a key query parameter for "Upload New...". self.assertTrue(asset_paths.does_path_match_base( "/canonical/base/", "canonical/base")) # 2) File path key query parameter, with absolute path. self.assertTrue(asset_paths.does_path_match_base( "/canonical/prefix/file.html", "canonical/prefix/")) # as_key(base) conversion. # Only leading and trailing / delimeter-stripped *exact* match, for # "Upload New..." key query paraemeter. self.assertTrue(asset_paths.does_path_match_base( "noncanonical/base", "/noncanonical/base/")) # Do *not* match partial prefixes without / delimiters. self.assertFalse(asset_paths.does_path_match_base( "noncanonical/basefile.jpg", "/noncanonical/base/")) # relative_base(base) conversion. # 1) Not a file path, but a key query parameter for "Upload New...". self.assertTrue(asset_paths.does_path_match_base( "relative/base/", "/relative/base")) # 2) File path key query parameter, with relative path. self.assertTrue(asset_paths.does_path_match_base( "relative/prefix/file.css", "/relative/prefix"))
def test_does_path_match_base(self): """Tests the does_path_match_base function.""" # as_base(base) canonicalizations: # 1) Not a file path, but a key query parameter for "Upload New...". self.assertTrue( asset_paths.does_path_match_base("/canonical/base/", "canonical/base")) # 2) File path key query parameter, with absolute path. self.assertTrue( asset_paths.does_path_match_base("/canonical/prefix/file.html", "canonical/prefix/")) # as_key(base) conversion. # Only leading and trailing / delimeter-stripped *exact* match, for # "Upload New..." key query paraemeter. self.assertTrue( asset_paths.does_path_match_base("noncanonical/base", "/noncanonical/base/")) # Do *not* match partial prefixes without / delimiters. self.assertFalse( asset_paths.does_path_match_base("noncanonical/basefile.jpg", "/noncanonical/base/")) # relative_base(base) conversion. # 1) Not a file path, but a key query parameter for "Upload New...". self.assertTrue( asset_paths.does_path_match_base("relative/base/", "/relative/base")) # 2) File path key query parameter, with relative path. self.assertTrue( asset_paths.does_path_match_base("relative/prefix/file.css", "/relative/prefix"))
def get_schema_details(cls, path): for base in cls._SCHEMAS.keys(): if asset_paths.does_path_match_base(path, base): return cls._SCHEMAS[base] return cls._UNKNOWN_SCHEMA