tests that history functions work with lazy-loading attributes
(self)
| 769 | assert unchanged == [el] |
| 770 | |
| 771 | def test_lazyhistory(self): |
| 772 | """tests that history functions work with lazy-loading attributes""" |
| 773 | |
| 774 | class Foo(BasicEntity): |
| 775 | pass |
| 776 | |
| 777 | class Bar(BasicEntity): |
| 778 | pass |
| 779 | |
| 780 | instrumentation.register_class(Foo) |
| 781 | instrumentation.register_class(Bar) |
| 782 | bar1, bar2, bar3, bar4 = [Bar(id=1), Bar(id=2), Bar(id=3), Bar(id=4)] |
| 783 | |
| 784 | def func1(state, passive): |
| 785 | return "this is func 1" |
| 786 | |
| 787 | def func2(state, passive): |
| 788 | return [bar1, bar2, bar3] |
| 789 | |
| 790 | _register_attribute( |
| 791 | Foo, "col1", uselist=False, callable_=func1, useobject=True |
| 792 | ) |
| 793 | _register_attribute( |
| 794 | Foo, "col2", uselist=True, callable_=func2, useobject=True |
| 795 | ) |
| 796 | _register_attribute(Bar, "id", uselist=False, useobject=True) |
| 797 | x = Foo() |
| 798 | attributes.instance_state(x)._commit_all(attributes.instance_dict(x)) |
| 799 | x.col2.append(bar4) |
| 800 | eq_( |
| 801 | attributes.get_state_history(attributes.instance_state(x), "col2"), |
| 802 | ([bar4], [bar1, bar2, bar3], []), |
| 803 | ) |
| 804 | |
| 805 | def test_parenttrack(self): |
| 806 | class Foo: |
nothing calls this directly
no test coverage detected