test similar to SelfReferentialTest.testmanytooneonly
(self)
| 326 | ) |
| 327 | |
| 328 | def test_many_to_one_only(self): |
| 329 | """test similar to SelfReferentialTest.testmanytooneonly""" |
| 330 | |
| 331 | Child1, Child2 = self.classes.Child1, self.classes.Child2 |
| 332 | |
| 333 | session = fixture_session() |
| 334 | |
| 335 | c1 = Child1() |
| 336 | c1.child1_data = "qwerty" |
| 337 | session.add(c1) |
| 338 | session.flush() |
| 339 | session.expunge_all() |
| 340 | |
| 341 | c1 = session.query(Child1).filter_by(child1_data="qwerty").one() |
| 342 | c2 = Child2() |
| 343 | c2.child1 = c1 |
| 344 | c2.child2_data = "asdfgh" |
| 345 | session.add(c2) |
| 346 | |
| 347 | # the flush will fail if the UOW does not set up a many-to-one DP |
| 348 | # attached to a task corresponding to c1, since "child1_id" is not |
| 349 | # nullable |
| 350 | session.flush() |
| 351 | |
| 352 | |
| 353 | class InheritTestTwo(fixtures.MappedTest): |
nothing calls this directly
no test coverage detected