def test_unmatch_snapshot_tree_prior_match(self):
        self._add_additional_fake_buildings()

        # simulate matching bs1 and bs2 to have a child of bs3
        self.bs1.children.add(self.bs3)
        self.bs2.children.add(self.bs3)

        canon = self.bs1.canonical_building
        canon2 = self.bs2.canonical_building
        canon2.active = False
        canon2.save()

        self.bs3.canonical_building = canon
        self.bs3.save()
        canon.canonical_snapshot = self.bs3
        canon.save()

        # now simulate matching bs4 and bs3 to have a child of bs5
        self.bs3.children.add(self.bs5)
        self.bs4.children.add(self.bs5)

        self.bs5.canonical_building = canon
        self.bs5.save()
        canon.canonical_snapshot = self.bs5
        canon.save()

        # simulating the following tree:
        # b1 b2
        # \ /
        #  b3 b4
        #  \ /
        #   b5

        # unmatch bs2 from bs1
        seed_models.unmatch_snapshot_tree(self.bs2.pk)

        canon = seed_models.CanonicalBuilding.objects.get(pk=canon.pk)
        canon2 = seed_models.CanonicalBuilding.objects.get(pk=canon2.pk)

        # bs3, and bs5 should be deleted
        deleted_pks = [self.bs3.pk, self.bs5.pk]
        bs_manager = seed_models.BuildingSnapshot.objects
        theoretically_empty_set = bs_manager.filter(pk__in=deleted_pks)

        self.assertEqual(theoretically_empty_set.count(), 0)

        bs2 = bs_manager.get(pk=self.bs2.pk)
        self.assertEqual(bs2.has_children, False)
        self.assertEqual(canon2.active, True)
"target database must support ON UPDATE..CASCADE behavior in
dataset/ETHPy150Open buildingenergy/buildingenergy-platform/seed/tests/test_models.py/TestBuildingSnapshot.test_unmatch_snapshot_tree_prior_match--crossover with--dataset/ETHPy150Open RoseOu/flasky/venv/lib/python2.7/site-packages/sqlalchemy/testing/requirements.py/SuiteRequirements.on_update_cascade