(self)
| 1065 | |
| 1066 | class UtilTest(fixtures.ORMTest): |
| 1067 | def test_helpers(self): |
| 1068 | class Foo: |
| 1069 | pass |
| 1070 | |
| 1071 | class Bar: |
| 1072 | pass |
| 1073 | |
| 1074 | instrumentation.register_class(Foo) |
| 1075 | instrumentation.register_class(Bar) |
| 1076 | _register_attribute(Foo, "coll", uselist=True, useobject=True) |
| 1077 | |
| 1078 | f1 = Foo() |
| 1079 | b1 = Bar() |
| 1080 | b2 = Bar() |
| 1081 | coll = attributes.init_collection(f1, "coll") |
| 1082 | assert coll.data is f1.coll |
| 1083 | assert attributes.get_attribute(f1, "coll") is f1.coll |
| 1084 | attributes.set_attribute(f1, "coll", [b1]) |
| 1085 | assert f1.coll == [b1] |
| 1086 | eq_(attributes.get_history(f1, "coll"), ([b1], [], [])) |
| 1087 | attributes.set_committed_value(f1, "coll", [b2]) |
| 1088 | eq_(attributes.get_history(f1, "coll"), ((), [b2], ())) |
| 1089 | |
| 1090 | attributes.del_attribute(f1, "coll") |
| 1091 | assert "coll" not in f1.__dict__ |
| 1092 | |
| 1093 | def test_set_committed_value_none_uselist(self): |
| 1094 | """test that set_committed_value->None to a uselist generates an |
nothing calls this directly
no test coverage detected