Exemplo n.º 1
0
    def test_default_region(self):
        # move the point outside the eco region
        self.plot.geom = Point(0, 0)
        self.plot.save_with_user(self.user)

        result = tree_benefits(instance=self.instance,
                               tree_id=self.tree.pk)
        bens_wo_default = result['benefits'][0]
        self.assert_benefit_value(bens_wo_default, 'energy', 'kwh', 0)
        self.assert_benefit_value(bens_wo_default, 'airquality', 'lbs/year', 0)
        self.assert_benefit_value(bens_wo_default, 'stormwater', 'gal', 0)
        self.assert_benefit_value(bens_wo_default, 'co2', 'lbs/year', 0)

        self.instance.itree_region_default = 'NoEastXXX'
        self.instance.save()
        result = tree_benefits(instance=self.instance,
                               tree_id=self.tree.pk)
        bens_with_default = result['benefits'][0]
        self.assert_benefit_value(bens_with_default,
                                  'energy', 'kwh', 1896)
        self.assert_benefit_value(bens_with_default,
                                  'airquality', 'lbs/year', 6)
        self.assert_benefit_value(bens_with_default,
                                  'stormwater', 'gal', 3185)
        self.assert_benefit_value(bens_with_default,
                                  'co2', 'lbs/year', 563)
Exemplo n.º 2
0
    def test_eco_benefit_sanity(self):
        rslt = tree_benefits(instance=self.instance,
                             tree_or_tree_id=self.tree)

        bens = rslt['tree_benefits']

        self.assert_benefit_value(bens, 'energy', 'kwh', 1896)
        self.assert_benefit_value(bens, 'airquality', 'lbs/year', 6)
        self.assert_benefit_value(bens, 'stormwater', 'gal', 3185)
        self.assert_benefit_value(bens, 'co2', 'lbs/year', 563)
Exemplo n.º 3
0
def tree_resource_to_dict(tree):
    if tree.species and tree.species.otm_code and tree.diameter:
        return tree_benefits(tree.instance, tree.pk)
    else:
        return {}