def test_delete_organization_buildings(self):
        # start with the normal use case
        bs1_data = {
            'pm_property_id': 123,
            'tax_lot_id': '435/422',
            'property_name': 'Greenfield Complex',
            'custom_id_1': 1243,
            'address_line_1': '555 NorthWest Databaseer Lane.',
            'address_line_2': '',
            'city': 'Gotham City',
            'postal_code': 8999,
        }
        # This building will have a lot less data to identify it.
        bs2_data = {
            'pm_property_id': 1243,
            'custom_id_1': 1243,
            'address_line_1': '555 Database LN.',
            'city': 'Gotham City',
            'postal_code': 8999,
        }
        new_import_file = ImportFile.objects.create(
            import_record=self.import_record,
            mapping_done=True
        )

        snapshot = util.make_fake_snapshot(
            self.import_file, bs1_data, ASSESSED_BS, is_canon=True
        )

        snapshot.super_organization = self.fake_org
        snapshot.save()

        snapshot = util.make_fake_snapshot(
            new_import_file,
            bs2_data, PORTFOLIO_BS
        )
        snapshot.super_organization = self.fake_org
        snapshot.save()

        tasks.match_buildings(new_import_file.pk, self.fake_user.pk)

        # make one more building snapshot in a different org
        fake_org_2 = Organization.objects.create()
        snapshot = util.make_fake_snapshot(
            self.import_file, bs1_data, ASSESSED_BS, is_canon=True
        )
        snapshot.super_organization = fake_org_2
        snapshot.save()

        self.assertGreater(BuildingSnapshot.objects.filter(
            super_organization=self.fake_org
        ).count(), 0)

        tasks.delete_organization_buildings(self.fake_org.pk)

        self.assertEqual(BuildingSnapshot.objects.filter(
            super_organization=self.fake_org
        ).count(), 0)

        self.assertGreater(BuildingSnapshot.objects.filter(
            super_organization=fake_org_2
        ).count(), 0)

        # test that the CanonicalBuildings are deleted
        self.assertEqual(CanonicalBuilding.objects.filter(
            canonical_snapshot__super_organization=self.fake_org
        ).count(), 0)
        # test that other orgs CanonicalBuildings are not deleted
        self.assertGreater(CanonicalBuilding.objects.filter(
            canonical_snapshot__super_organization=fake_org_2
        ).count(), 0)
Set attribute to current task's space.
dataset/ETHPy150Open buildingenergy/buildingenergy-platform/seed/tests/test_tasks.py/TestTasks.test_delete_organization_buildings--crossover with--dataset/ETHPy150Open klen/muffin/muffin/utils.py/slocal.__setattr__