def test_modify_existing_XDATA(self, list1): xlist = XDataUserList(XData([list1])) xlist[0] = 3.1415 xlist[1] = 256 xlist.commit() tags = xlist.xdata.get("EZDXF") assert tags == [ dxftag(1001, "EZDXF"), dxftag(1000, "DefaultList"), dxftag(1002, "{"), dxftag(1040, 3.1415), dxftag(1071, 256), dxftag(1002, "}"), ]
def test_commit_creates_valid_XDATA(self): xlist = XDataUserList() xlist.extend(["String", Vec3(1, 2, 3), 3.1415, 256]) xlist.commit() tags = xlist.xdata.get("EZDXF") assert tags == [ dxftag(1001, "EZDXF"), dxftag(1000, "DefaultList"), dxftag(1002, "{"), dxftag(1000, "String"), dxftag(1010, (1, 2, 3)), dxftag(1040, 3.1415), dxftag(1071, 256), dxftag(1002, "}"), ]
def test_modify_existing_user_list(self, user_list): xlist = XDataUserList(XData([user_list]), name="MyUserList", appid="MyAppID") xlist[0] = 3.1415 xlist[1] = 256 xlist.commit() tags = xlist.xdata.get("MyAppID") assert tags == [ dxftag(1001, "MyAppID"), dxftag(1000, "MyUserList"), dxftag(1002, "{"), dxftag(1040, 3.1415), dxftag(1071, 256), dxftag(1002, "}"), ]
def test_commit_replaces_existing_XDATA(self, list1): xlist = XDataUserList(XData([list1])) xlist.clear() xlist.extend(["String", Vec3(1, 2, 3), 3.1415, 256]) xlist.commit() tags = xlist.xdata.get("EZDXF") assert tags == [ dxftag(1001, "EZDXF"), dxftag(1000, "DefaultList"), dxftag(1002, "{"), dxftag(1000, "String"), dxftag(1010, (1, 2, 3)), dxftag(1040, 3.1415), dxftag(1071, 256), dxftag(1002, "}"), ]
def test_too_long_string_raise_exception(self): # The XDATA limit for group code 1000 is 255 characters xlist = XDataUserList() xlist.append("0123456789" * 26) with pytest.raises(DXFValueError): xlist.commit()
def test_invalid_line_break_characters_raise_exception(self, char): xlist = XDataUserList() xlist.append(char) with pytest.raises(DXFValueError): xlist.commit()