Beispiel #1
0
class NearestPlotPyTest(TestCase):
    fixtures = ['test_treelive_summary', 'test_idb_summary', 'test_conditionvariantlookup']

    def setUp(self):
        self.client = Client()
        self.user = User.objects.create_user(
            'featuretest', '*****@*****.**', password='******')
        self.prop1 = ForestProperty(user=self.user, name="My Property", geometry_final=p1)
        self.prop1.save()
        self.stand1 = Stand(user=self.user, name="My Stand", geometry_orig=g1) 
        self.stand1.save()
        self.stand1.add_to_collection(self.prop1)

    def _create_strata(self):
        stand_list = {
            'property': self.prop1.uid,
            'classes': [
                ('Douglas-fir', 2, 4, 145),
            ]
        }
        strata = Strata(user=self.user, name="My Strata", search_age=30.0, search_tpa=120.0, stand_list = stand_list)
        strata.save()
        return strata

    def test_bad_stand_list(self):
        stand_list = [ ('Douglas-fir', 2, 4, 145), ] 
        strata = Strata(user=self.user, name="My Strata", search_age=30.0, search_tpa=120.0, stand_list=stand_list)
        with self.assertRaises(ValidationError):
            strata.save()

        stand_list = {
            'property': self.prop1.uid,
            'classes': [
                ('Douglas-fir', "booo"),
            ]
        }
        strata = Strata(user=self.user, name="My Strata", search_age=30.0, search_tpa=120.0, stand_list=stand_list)
        with self.assertRaises(ValidationError):
            strata.save()

    def test_assign_strata_to_stand(self):
        strata = self._create_strata()
        self.assertTrue(strata)
        self.stand1.strata = strata
        self.assertEqual("My Strata", self.stand1.strata.name)

    def test_candidates(self):
        from trees.plots import get_candidates
        stand_list = {
            'property': self.prop1.uid,
            'classes': [('Douglas-fir', 2, 4, 145), ]
        }
        variant = self.prop1.variant.code
        get_candidates(stand_list['classes'], variant)
Beispiel #2
0
class NearestPlotPyTest(TestCase):
    fixtures = ['test_treelive_summary', 'test_idb_summary', 'test_conditionvariantlookup']

    def setUp(self):
        self.client = Client()
        self.user = User.objects.create_user(
            'featuretest', '*****@*****.**', password='******')
        self.prop1 = ForestProperty(user=self.user, name="My Property", geometry_final=p1)
        self.prop1.save()
        self.stand1 = Stand(user=self.user, name="My Stand", geometry_orig=g1)
        self.stand1.save()
        self.stand1.add_to_collection(self.prop1)

    def _create_strata(self):
        stand_list = {
            'property': self.prop1.uid,
            'classes': [
                ('Douglas-fir', 2, 4, 145),
            ]
        }
        strata = Strata(user=self.user, name="My Strata", search_age=30.0, search_tpa=120.0, stand_list = stand_list)
        strata.save()
        return strata

    def test_bad_stand_list(self):
        stand_list = [ ('Douglas-fir', 2, 4, 145), ]
        strata = Strata(user=self.user, name="My Strata", search_age=30.0, search_tpa=120.0, stand_list=stand_list)
        with self.assertRaises(ValidationError):
            strata.save()

        stand_list = {
            'property': self.prop1.uid,
            'classes': [
                ('Douglas-fir', "booo"),
            ]
        }
        strata = Strata(user=self.user, name="My Strata", search_age=30.0, search_tpa=120.0, stand_list=stand_list)
        with self.assertRaises(ValidationError):
            strata.save()

    def test_assign_strata_to_stand(self):
        strata = self._create_strata()
        self.assertTrue(strata)
        self.stand1.strata = strata
        self.assertEqual("My Strata", self.stand1.strata.name)

    def test_candidates(self):
        from trees.plots import get_candidates
        stand_list = {
            'property': self.prop1.uid,
            'classes': [('Douglas-fir', 2, 4, 145), ]
        }
        variant = self.prop1.variant.code
        get_candidates(stand_list['classes'], variant)
Beispiel #3
0
class ForestPropertyTest(TestCase):
    '''
    Basic tests for adding/removing stands from a property
    '''

    def setUp(self):
        self.client = Client()
        self.user = User.objects.create_user(
            'featuretest', '*****@*****.**', password='******')

        self.stand1 = Stand(user=self.user, name="My Stand", geometry_orig=g1)
        self.stand1.save()

    def test_create_property(self):
        prop1 = ForestProperty(user=self.user, name="My Property", geometry_final=p1)
        prop1.save()

    def test_property_bbox(self):
        prop1 = ForestProperty(user=self.user, name="My Property", geometry_final=p1)
        prop1.save()
        self.assertEqual(prop1.bbox, p1.extent)

    def test_add_property_to_stand(self):
        prop1 = ForestProperty(user=self.user, name="My Property", geometry_final=p1)
        prop1.save()

        self.stand1.add_to_collection(prop1)
        self.assertEqual(self.stand1.collection, prop1)
        self.assertTrue(self.stand1 in prop1.feature_set())

        self.stand1.remove_from_collection()
        self.assertEqual(self.stand1.collection, None)
        self.assertTrue(self.stand1 not in prop1.feature_set())

    def test_add_stand_to_property(self):
        prop1 = ForestProperty(user=self.user, name="My Property", geometry_final=p1)
        prop1.save()

        prop1.add(self.stand1)
        self.assertEqual(self.stand1.collection, prop1)
        self.assertTrue(self.stand1 in prop1.feature_set())

        prop1.remove(self.stand1)
        self.assertEqual(self.stand1.collection, None)
        self.assertTrue(self.stand1 not in prop1.feature_set())

    def test_add_property_to_property(self):
        prop1 = ForestProperty(user=self.user, name="My Property", geometry_final=p1)
        prop2 = ForestProperty(user=self.user, name="My Property", geometry_final=p1)
        prop1.save()
        prop2.save()
        # This `prop1.add(prop2)` should fail
        self.assertRaises(AssertionError, prop1.add, prop2)
Beispiel #4
0
class ForestPropertyTest(TestCase):
    '''
    Basic tests for adding/removing stands from a property
    '''

    def setUp(self):
        self.client = Client()
        self.user = User.objects.create_user(
            'featuretest', '*****@*****.**', password='******')

        self.stand1 = Stand(user=self.user, name="My Stand", geometry_orig=g1) 
        self.stand1.save()

    def test_create_property(self):
        prop1 = ForestProperty(user=self.user, name="My Property", geometry_final=p1)
        prop1.save()

    def test_property_bbox(self):
        prop1 = ForestProperty(user=self.user, name="My Property", geometry_final=p1)
        prop1.save()
        self.assertEqual(prop1.bbox, p1.extent)

    def test_add_property_to_stand(self):
        prop1 = ForestProperty(user=self.user, name="My Property", geometry_final=p1)
        prop1.save()

        self.stand1.add_to_collection(prop1)
        self.assertEqual(self.stand1.collection, prop1)
        self.assertTrue(self.stand1 in prop1.feature_set())

        self.stand1.remove_from_collection()
        self.assertEqual(self.stand1.collection, None)
        self.assertTrue(self.stand1 not in prop1.feature_set())

    def test_add_stand_to_property(self):
        prop1 = ForestProperty(user=self.user, name="My Property", geometry_final=p1)
        prop1.save()

        prop1.add(self.stand1)
        self.assertEqual(self.stand1.collection, prop1)
        self.assertTrue(self.stand1 in prop1.feature_set())

        prop1.remove(self.stand1)
        self.assertEqual(self.stand1.collection, None)
        self.assertTrue(self.stand1 not in prop1.feature_set())

    def test_add_property_to_property(self):
        prop1 = ForestProperty(user=self.user, name="My Property", geometry_final=p1)
        prop2 = ForestProperty(user=self.user, name="My Property", geometry_final=p1)
        prop1.save()
        prop2.save()
        # This `prop1.add(prop2)` should fail
        self.assertRaises(AssertionError, prop1.add, prop2)