def test_finderinfo_color_set_get_clear(temp_file): """Test ability to set_attribute, get_attribute, clear_attribute on finderinfo""" from osxmetadata import OSXMetaData, Tag from osxmetadata.constants import FINDER_COLOR_GREEN, FINDER_COLOR_BLUE from osxmetadata.findertags import get_tag_color_name meta = OSXMetaData(temp_file) assert meta.finderinfo.color == 0 meta.finderinfo.color = FINDER_COLOR_GREEN assert meta.finderinfo.color == FINDER_COLOR_GREEN assert {"color": FINDER_COLOR_GREEN}.items() <= meta.get_attribute( "finderinfo" ).items() meta.set_attribute("finderinfo", {"color": FINDER_COLOR_BLUE}) assert meta.finderinfo.color == FINDER_COLOR_BLUE meta.clear_attribute("finderinfo") assert meta.finderinfo.color == 0 meta.finderinfo.color = FINDER_COLOR_GREEN meta.finderinfo.color = None assert meta.finderinfo.color == 0 meta.finderinfo.color = FINDER_COLOR_GREEN meta.finderinfo = None assert meta.finderinfo.color == 0
def test_finderinfo_stationarypad_and_color(temp_file): """Test ability to modify color and stationary pad independently""" from osxmetadata import OSXMetaData, Tag from osxmetadata.constants import ( FINDER_COLOR_GREEN, FINDER_COLOR_BLUE, FINDER_COLOR_NONE, ) meta = OSXMetaData(temp_file) assert meta.finderinfo.stationarypad == 0 assert meta.finderinfo.color == FINDER_COLOR_NONE meta.finderinfo.stationarypad = True assert meta.finderinfo.stationarypad assert meta.finderinfo.color == FINDER_COLOR_NONE meta.finderinfo.color = FINDER_COLOR_GREEN assert meta.finderinfo.color == FINDER_COLOR_GREEN assert meta.finderinfo.stationarypad meta.finderinfo.stationarypad = False assert not meta.finderinfo.stationarypad assert meta.finderinfo.color == FINDER_COLOR_GREEN assert { "color": FINDER_COLOR_GREEN, "stationarypad": False, }.items() <= meta.get_attribute("finderinfo").items() meta.set_attribute("finderinfo", {"stationarypad": True}) assert meta.finderinfo.stationarypad assert meta.finderinfo.color == FINDER_COLOR_GREEN meta.set_attribute("finderinfo", {"color": FINDER_COLOR_BLUE}) assert meta.finderinfo.color == FINDER_COLOR_BLUE assert meta.finderinfo.stationarypad meta.finderinfo = {"color": FINDER_COLOR_GREEN} assert meta.finderinfo.color == FINDER_COLOR_GREEN assert meta.finderinfo.stationarypad meta.finderinfo = {"stationarypad": False} assert meta.finderinfo.color == FINDER_COLOR_GREEN assert not meta.finderinfo.stationarypad