Beispiel #1
0
    def test_otm_id(self):
        # silly invalid-int-errors should be caught
        i = self.mkrow({
            'point x': '16',
            'point y': '20',
            'opentreemap id number': '44b'
        })
        r = i.validate_row()

        self.assertFalse(r)
        self.assertHasError(i, errors.INT_ERROR, None)

        i = self.mkrow({
            'point x': '16',
            'point y': '20',
            'opentreemap id number': '-22'
        })
        r = i.validate_row()

        self.assertFalse(r)
        self.assertHasError(i, errors.POS_INT_ERROR)

        # With no plots in the system, all ids should fail
        i = self.mkrow({
            'point x': '16',
            'point y': '20',
            'opentreemap id number': '44'
        })
        r = i.validate_row()

        self.assertFalse(r)
        self.assertHasError(i, errors.INVALID_OTM_ID)

        # Add in plot
        setupTreemapEnv()  # We need the whole darn thing
        # just so we can add a plot :(

        # SetupTME provides a special user for us to use
        # as well as particular neighborhood
        user = User.objects.get(username="******")
        p = mkPlot(user, geom=Point(25, 25))
        p.save()

        # With an existing plot it should be fine
        i = self.mkrow({
            'point x': '16',
            'point y': '20',
            'opentreemap id number': p.pk
        })
        r = i.validate_row()

        self.assertNotHasError(i, errors.INVALID_OTM_ID)
        self.assertNotHasError(i, errors.INT_ERROR)
Beispiel #2
0
    def test_proximity(self):
        setupTreemapEnv()

        user = User.objects.get(username="******")
        bie1 = ImportEvent(file_name="bie1")
        bie2 = ImportEvent(file_name="bie2")
        bie3 = ImportEvent(file_name="bie3")
        bie4 = ImportEvent(file_name="bie4")

        for bie in [bie1, bie2, bie3, bie4]:
            bie.save()

        p1 = mkPlot(user, geom=Point(25.0000001,25.0000001))
        p1.import_event = bie1
        p1.save()

        p2 = mkPlot(user, geom=Point(25.0000002,25.0000002))
        p2.import_event = bie2
        p2.save()

        p3 = mkPlot(user, geom=Point(25.0000003,25.0000003))
        p3.import_event = bie3
        p3.save()

        p4 = mkPlot(user, geom=Point(27.0000001,27.0000001))
        p4.import_event = bie4
        p4.save()

        n1 = { p.pk for p in [p1,p2,p3] }
        n2 = { p4.pk }

        i = self.mkrow({'point x': '25.00000025',
                        'point y': '25.00000025'})
        r = i.validate_row()

        self.assertHasError(i, errors.NEARBY_TREES, n1, set)

        i = self.mkrow({'point x': '27.00000015',
                        'point y': '27.00000015'})
        r = i.validate_row()

        self.assertHasError(i, errors.NEARBY_TREES, n2, set)

        i = self.mkrow({'point x': '30.00000015',
                        'point y': '30.00000015'})
        r = i.validate_row()

        self.assertNotHasError(i, errors.NEARBY_TREES)
Beispiel #3
0
    def setUp(self):
        self.instance = setupTreemapEnv()

        self.user = make_admin_user(self.instance)

        ss = Species.objects.all()
        self.s1 = ss[0]
        self.s2 = ss[1]
Beispiel #4
0
    def setUp(self):
        self.instance = setupTreemapEnv()

        self.user = make_admin_user(self.instance)

        ss = Species.objects.all()
        self.s1 = ss[0]
        self.s2 = ss[1]
Beispiel #5
0
    def test_otm_id(self):
        # silly invalid-int-errors should be caught
        i = self.mkrow({'point x': '16',
                        'point y': '20',
                        'opentreemap id number': '44b'})
        r = i.validate_row()

        self.assertFalse(r)
        self.assertHasError(i, errors.INT_ERROR, None)

        i = self.mkrow({'point x': '16',
                        'point y': '20',
                        'opentreemap id number': '-22'})
        r = i.validate_row()

        self.assertFalse(r)
        self.assertHasError(i, errors.POS_INT_ERROR)

        # With no plots in the system, all ids should fail
        i = self.mkrow({'point x': '16',
                        'point y': '20',
                        'opentreemap id number': '44'})
        r = i.validate_row()

        self.assertFalse(r)
        self.assertHasError(i, errors.INVALID_OTM_ID)

        # Add in plot
        setupTreemapEnv() # We need the whole darn thing
                          # just so we can add a plot :(

        # SetupTME provides a special user for us to use
        # as well as particular neighborhood
        user = User.objects.get(username="******")
        p = mkPlot(user, geom=Point(25,25))
        p.save()

        # With an existing plot it should be fine
        i = self.mkrow({'point x': '16',
                        'point y': '20',
                        'opentreemap id number': p.pk})
        r = i.validate_row()

        self.assertNotHasError(i, errors.INVALID_OTM_ID)
        self.assertNotHasError(i, errors.INT_ERROR)
Beispiel #6
0
    def test_proximity(self):
        setupTreemapEnv()

        user = User.objects.get(username="******")
        bie1 = ImportEvent(file_name="bie1")
        bie2 = ImportEvent(file_name="bie2")
        bie3 = ImportEvent(file_name="bie3")
        bie4 = ImportEvent(file_name="bie4")

        for bie in [bie1, bie2, bie3, bie4]:
            bie.save()

        p1 = mkPlot(user, geom=Point(25.0000001, 25.0000001))
        p1.import_event = bie1
        p1.save()

        p2 = mkPlot(user, geom=Point(25.0000002, 25.0000002))
        p2.import_event = bie2
        p2.save()

        p3 = mkPlot(user, geom=Point(25.0000003, 25.0000003))
        p3.import_event = bie3
        p3.save()

        p4 = mkPlot(user, geom=Point(27.0000001, 27.0000001))
        p4.import_event = bie4
        p4.save()

        n1 = {p.pk for p in [p1, p2, p3]}
        n2 = {p4.pk}

        i = self.mkrow({'point x': '25.00000025', 'point y': '25.00000025'})
        r = i.validate_row()

        self.assertHasError(i, errors.NEARBY_TREES, n1, set)

        i = self.mkrow({'point x': '27.00000015', 'point y': '27.00000015'})
        r = i.validate_row()

        self.assertHasError(i, errors.NEARBY_TREES, n2, set)

        i = self.mkrow({'point x': '30.00000015', 'point y': '30.00000015'})
        r = i.validate_row()

        self.assertNotHasError(i, errors.NEARBY_TREES)
Beispiel #7
0
    def setUp(self):
        self.instance = setupTreemapEnv()

        self.user = make_admin_user(self.instance)
Beispiel #8
0
    def setUp(self):
        setupTreemapEnv()

        self.user = User.objects.get(username='******')
Beispiel #9
0
    def setUp(self):
        self.instance = setupTreemapEnv()

        self.user = make_admin_user(self.instance)
Beispiel #10
0
    def setUp(self):
        setupTreemapEnv()

        self.user = User.objects.get(username='******')