• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python models.Species类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中treemap.models.Species的典型用法代码示例。如果您正苦于以下问题:Python Species类的具体用法?Python Species怎么用?Python Species使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Species类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_faulty_data1

    def test_faulty_data1(self):
        s1_g = Species(instance=self.instance, genus="g1", species="", cultivar="", max_diameter=50.0, max_height=100.0)
        s1_g.save_with_system_user_bypass_auth()

        # TODO: READONLY restore when implemented
        # csv = """
        # | point x | point y | diameter | read only | genus | tree height |
        # | -34.2   | 24.2    | q12      | true      |       |             |
        # | 323     | 23.2    | 14       | falseo    |       |             |
        # | 32.1    | 22.4    | 15       | true      |       |             |
        # | 33.2    | 19.1    | 32       | true      |       |             |
        # | 33.2    | q19.1   | -33.3    | true      | gfail |             |
        # | 32.1    | 12.1    |          | false     | g1    | 200         |
        # | 32.1    | 12.1    | 300      | false     | g1    |             |
        # """
        csv = """
        | point x | point y | diameter | genus | tree height |
        | -34.2   | 24.2    | q12      |       |             |
        | 323     | 23.2    | 14       |       |             |
        | 32.1    | 22.4    | 15       |       |             |
        | 33.2    | 19.1    | 32       |       |             |
        | 33.2    | q19.1   | -33.3    | gfail |             |
        | 32.1    | 12.1    |          | g1    | 200         |
        | 32.1    | 12.1    | 300      | g1    |             |
        """

        gflds = [fields.trees.POINT_X, fields.trees.POINT_Y]
        sflds = [
            fields.trees.GENUS,
            fields.trees.SPECIES,
            fields.trees.CULTIVAR,
            fields.trees.OTHER_PART_OF_NAME,
            fields.trees.COMMON_NAME,
        ]

        j = self.run_through_process_views(csv)
        ierrors = self.extract_errors(j)
        self.assertEqual(ierrors["0"], [(errors.FLOAT_ERROR[0], [fields.trees.DIAMETER], None)])

        # TODO: READONLY restore when implemented
        # self.assertEqual(ierrors['1'],
        #                  [(errors.BOOL_ERROR[0],
        #                    [fields.trees.READ_ONLY], None),
        #                   (errors.INVALID_GEOM[0], gflds, None)])
        self.assertEqual(ierrors["1"], [(errors.INVALID_GEOM[0], gflds, None)])

        self.assertNotIn("2", ierrors)
        self.assertNotIn("3", ierrors)
        self.assertEqual(
            ierrors["4"],
            [
                (errors.POS_FLOAT_ERROR[0], [fields.trees.DIAMETER], None),
                (errors.FLOAT_ERROR[0], [fields.trees.POINT_Y], None),
                (errors.MISSING_FIELD[0], gflds, None),
                (errors.INVALID_SPECIES[0], sflds, "gfail"),
            ],
        )
        self.assertEqual(ierrors["5"], [(errors.SPECIES_HEIGHT_TOO_HIGH[0], [fields.trees.TREE_HEIGHT], 100.0)])
        self.assertEqual(ierrors["6"], [(errors.SPECIES_DBH_TOO_HIGH[0], [fields.trees.DIAMETER], 50.0)])
开发者ID:recklessromeo,项目名称:otm-core,代码行数:59,代码来源:tests.py


示例2: test_update_species

 def test_update_species(self):
     with self._assert_updates_eco_rev(True):
         tree = Tree(instance=self.instance, plot=self.plot)
         tree.save_with_user(self.user)
         species = Species(common_name='foo', instance=self.instance)
         species.save_with_user(self.user)
         request_dict = {'tree.species': species.pk}
         update_map_feature(request_dict, self.user, self.plot)
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:8,代码来源:test_map_feature.py


示例3: setUp

    def setUp(self):
        instance = make_instance()
        user = make_admin_user(instance)

        species = Species(instance=instance, genus="g1", species="", cultivar="", max_diameter=50.0, max_height=100.0)
        species.save_with_user(User.system_user())

        login(self.client, user.username)
开发者ID:recklessromeo,项目名称:otm-core,代码行数:8,代码来源:tests.py


示例4: EcoTest

class EcoTest(TestCase):
    def setUp(self):
        self.factory = RequestFactory()

        self.instance, system_user = tm.make_instance_and_system_user()

        self.user = User(username="commander")
        self.user.save_with_user(system_user)
        self.user.roles.add(tm.make_commander_role(self.instance))

        self.species = Species(symbol='CEDR',
                               genus='cedrus',
                               species='atlantica',
                               max_dbh=2000,
                               max_height=100)
        self.species.save()

        p1 = Point(-8515941.0, 4953519.0)
        self.plot = Plot(geom=p1,
                         instance=self.instance,
                         created_by=self.user)

        self.plot.save_with_user(self.user)

        self.tree = Tree(plot=self.plot,
                         instance=self.instance,
                         readonly=False,
                         species=self.species,
                         diameter=1630,
                         created_by=self.user)

        self.tree.save_with_user(self.user)

    def test_group_eco(self):
        pass  # TODO: Once filtering has been enabled

    def test_eco_benefit_sanity(self):
        req = self.factory.get('/%s/eco/benefit/tree/%s/' %
                              (self.instance.pk, self.tree.pk))

        response = tree_benefits(req,
                                 instance_id=self.instance.pk,
                                 tree_id=self.tree.pk,
                                 region='NoEastXXX')

        self.assertEqual(response.status_code, 200)
        rslt = json.loads(response.content)

        bens = rslt['benefits']

        def assertBValue(benefit, unit, value):
            self.assertEqual(bens[benefit]['unit'], unit)
            self.assertEqual(int(float(bens[benefit]['value'])), value)

        assertBValue('energy', 'kwh', 1896)
        assertBValue('airquality', 'lbs/year', 6)
        assertBValue('stormwater', 'gal', 3185)
        assertBValue('co2', 'lbs/year', 563)
开发者ID:balexandrowicz,项目名称:OTM2,代码行数:58,代码来源:tests.py


示例5: test_height_too_large_for_species_fails_validation

 def test_height_too_large_for_species_fails_validation(self):
     max_height = 1
     s = Species(genus='Ulmus', species='rubra', cultivar='Columella',
                 instance=self.instance, max_height=max_height)
     s.save_with_user(self.user)
     self.tree.species = s
     self.tree.height = str(max_height + 1)
     with self.assertRaises(ValidationError) as cm:
         self.tree.save_with_user(self.user)
     self.assertValidationErrorDictContainsKey(cm.exception, 'height')
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:10,代码来源:test_models.py


示例6: commit_row

    def commit_row(self):
        # First validate
        if not self.validate_row():
            return False

        # Get our data
        data = self.cleaned

        species_edited = False

        # Initially grab species from row if it exists
        # and edit it
        species = self.species

        # If not specified create a new one
        if species is None:
            species = Species()

        # Convert units
        self.convert_units(data, {
            fields.species.MAX_DIAMETER:
            self.import_event.max_diameter_conversion_factor,

            fields.species.MAX_HEIGHT:
            self.import_event.max_tree_height_conversion_factor
        })

        #TODO: Update tree count nonsense

        for modelkey, importdatakey in SpeciesImportRow.SPECIES_MAP.iteritems():
            importdata = data.get(importdatakey, None)

            if importdata is not None:
                species_edited = True
                setattr(species, modelkey, importdata)

        if species_edited:
            species.save()

        resource = data[fields.species.RESOURCE]

        species.resource.clear()
        species.resource.add(resource)

        species.save()
        resource.save()

        self.species = species
        self.status = TreeImportRow.SUCCESS
        self.save()

        return True
开发者ID:OpenTreeMap,项目名称:otm-legacy,代码行数:52,代码来源:models.py


示例7: test_faulty_data1

    def test_faulty_data1(self):
        s1_g = Species(symbol='S1GSC', scientific_name='',family='',
                       genus='g1', species='', cultivar_name='',
                       v_max_dbh=50.0, v_max_height=100.0)
        s1_g.save()

        csv = """
        | point x | point y | diameter | read only | condition | genus | tree height |
        | -34.2   | 24.2    | q12      | true      | Dead      |       |         |
        | 323     | 23.2    | 14       | falseo    | Critical  |       |         |
        | 32.1    | 22.4    | 15       | true      | Dead      |       |         |
        | 33.2    | 19.1    | 32       | true      | Arg       |       |         |
        | 33.2    | q19.1   | -33.3    | true      | Dead      | gfail |         |
        | 32.1    | 12.1    |          | false     | Dead      | g1    | 200     |
        | 32.1    | 12.1    | 300      | false     | Dead      | g1    |         |
        | 11.1    | 12.1    |          | false     | Dead      |       |         |
        """

        gflds = [fields.trees.POINT_X, fields.trees.POINT_Y]
        sflds = [fields.trees.GENUS, fields.trees.SPECIES, fields.trees.CULTIVAR]

        j = self.run_through_process_views(csv)
        ierrors = self.extract_errors(j)
        self.assertEqual(ierrors['0'],
                         [(errors.FLOAT_ERROR[0],
                           [fields.trees.DIAMETER], None),
                          (errors.GEOM_OUT_OF_BOUNDS[0], gflds, None)])

        self.assertEqual(ierrors['1'],
                         [(errors.BOOL_ERROR[0],
                           [fields.trees.READ_ONLY], None),
                          (errors.INVALID_GEOM[0], gflds, None)])
        self.assertNotIn('2', ierrors)
        self.assertEqual(ierrors['3'],
                         [(errors.INVALID_CHOICE[0],
                           [fields.trees.TREE_CONDITION], 'conditions')])
        self.assertEqual(ierrors['4'],
                         [(errors.POS_FLOAT_ERROR[0],
                           [fields.trees.DIAMETER], None),
                          (errors.FLOAT_ERROR[0],
                           [fields.trees.POINT_Y], None),
                          (errors.MISSING_POINTS[0], gflds, None),
                          (errors.INVALID_SPECIES[0], sflds, 'gfail')])
        self.assertEqual(ierrors['5'],
                         [(errors.SPECIES_HEIGHT_TOO_HIGH[0],
                           [fields.trees.TREE_HEIGHT], 100.0)])
        self.assertEqual(ierrors['6'],
                         [(errors.SPECIES_DBH_TOO_HIGH[0],
                           [fields.trees.DIAMETER], 50.0)])
        self.assertEqual(ierrors['7'],
                         [(errors.EXCL_ZONE[0], gflds, None)])
开发者ID:OpenTreeMap,项目名称:otm-legacy,代码行数:51,代码来源:tests.py


示例8: setUp

    def setUp(self):
        self.factory = RequestFactory()

        self.instance, system_user = tm.make_instance_and_system_user()

        self.user = User(username="commander")
        self.user.save_with_user(system_user)
        self.user.roles.add(tm.make_commander_role(self.instance))

        self.species = Species(symbol='CEDR',
                               genus='cedrus',
                               species='atlantica',
                               max_dbh=2000,
                               max_height=100)
        self.species.save()

        p1 = Point(-8515941.0, 4953519.0)
        self.plot = Plot(geom=p1,
                         instance=self.instance,
                         created_by=self.user)

        self.plot.save_with_user(self.user)

        self.tree = Tree(plot=self.plot,
                         instance=self.instance,
                         readonly=False,
                         species=self.species,
                         diameter=1630,
                         created_by=self.user)

        self.tree.save_with_user(self.user)
开发者ID:balexandrowicz,项目名称:OTM2,代码行数:31,代码来源:tests.py


示例9: setUp

    def setUp(self):
        region = ITreeRegion.objects.get(code='NoEastXXX')
        p = region.geometry.point_on_surface

        self.instance = make_instance(is_public=True, point=p)

        self.user = make_commander_user(self.instance)

        self.species = Species(otm_code='CEAT',
                               genus='cedrus',
                               species='atlantica',
                               max_dbh=2000,
                               max_height=100,
                               instance=self.instance)
        self.species.save_with_user(self.user)

        self.plot = Plot(geom=p, instance=self.instance)

        self.plot.save_with_user(self.user)

        self.tree = Tree(plot=self.plot,
                         instance=self.instance,
                         readonly=False,
                         species=self.species,
                         diameter=1630)

        self.tree.save_with_user(self.user)
开发者ID:ahinz,项目名称:OpenTreeMap-cloud,代码行数:27,代码来源:ecobenefits.py


示例10: test_faulty_data1

    def test_faulty_data1(self):
        s1_g = Species(instance=self.instance, genus='g1', species='',
                       cultivar='', max_diameter=50.0, max_height=100.0)
        s1_g.save_with_system_user_bypass_auth()

        csv = """
        | point x | point y | diameter | read only | genus | tree height |
        | -34.2   | 24.2    | q12      | true      |       |             |
        | 323     | 23.2    | 14       | falseo    |       |             |
        | 32.1    | 22.4    | 15       | true      |       |             |
        | 33.2    | 19.1    | 32       | true      |       |             |
        | 33.2    | q19.1   | -33.3    | true      | gfail |             |
        | 32.1    | 12.1    |          | false     | g1    | 200         |
        | 32.1    | 12.1    | 300      | false     | g1    |             |
        """

        gflds = [fields.trees.POINT_X, fields.trees.POINT_Y]
        sflds = [fields.trees.GENUS, fields.trees.SPECIES,
                 fields.trees.CULTIVAR]

        j = self.run_through_process_views(csv)
        ierrors = self.extract_errors(j)
        self.assertEqual(ierrors['0'],
                         [(errors.FLOAT_ERROR[0],
                           [fields.trees.DIAMETER], None)])

        self.assertEqual(ierrors['1'],
                         [(errors.BOOL_ERROR[0],
                           [fields.trees.READ_ONLY], None),
                          (errors.INVALID_GEOM[0], gflds, None)])
        self.assertNotIn('2', ierrors)
        self.assertNotIn('3', ierrors)
        self.assertEqual(ierrors['4'],
                         [(errors.POS_FLOAT_ERROR[0],
                           [fields.trees.DIAMETER], None),
                          (errors.FLOAT_ERROR[0],
                           [fields.trees.POINT_Y], None),
                          (errors.MISSING_FIELD[0], gflds, None),
                          (errors.INVALID_SPECIES[0], sflds, 'gfail')])
        self.assertEqual(ierrors['5'],
                         [(errors.SPECIES_HEIGHT_TOO_HIGH[0],
                           [fields.trees.TREE_HEIGHT], 100.0)])
        self.assertEqual(ierrors['6'],
                         [(errors.SPECIES_DBH_TOO_HIGH[0],
                           [fields.trees.DIAMETER], 50.0)])
开发者ID:jordanbaumgardner,项目名称:OTM2,代码行数:45,代码来源:tests.py


示例11: setUp

    def setUp(self):
        # Example url for
        # CEAT, 1630 dbh, NoEastXXX
        # eco.json?otmcode=CEAT&diameter=1630&region=NoEastXXX
        def mockbenefits(*args, **kwargs):
            benefits = {
                "Benefits": {
                    "aq_nox_avoided": 0.6792,
                    "aq_nox_dep": 0.371,
                    "aq_ozone_dep": 0.775,
                    "aq_pm10_avoided": 0.0436,
                    "aq_pm10_dep": 0.491,
                    "aq_sox_avoided": 0.372,
                    "aq_sox_dep": 0.21,
                    "aq_voc_avoided": 0.0254,
                    "bvoc": -0.077,
                    "co2_avoided": 255.5,
                    "co2_sequestered": 0,
                    "co2_storage": 6575,
                    "electricity": 187,
                    "hydro_interception": 12.06,
                    "natural_gas": 5834.1
                }
            }
            return (benefits, None)

        region = ITreeRegion.objects.get(code='NoEastXXX')
        p = region.geometry.point_on_surface

        self.instance = make_instance(is_public=True, point=p)
        self.user = make_commander_user(self.instance)

        self.species = Species(otm_code='CEAT',
                               genus='cedrus',
                               species='atlantica',
                               max_dbh=2000,
                               max_height=100,
                               instance=self.instance)

        self.species.save_with_user(self.user)

        self.plot = Plot(geom=p, instance=self.instance)

        self.plot.save_with_user(self.user)

        self.tree = Tree(plot=self.plot,
                         instance=self.instance,
                         readonly=False,
                         species=self.species,
                         diameter=1630)

        self.tree.save_with_user(self.user)

        self.origBenefitFn = ecobackend.json_benefits_call
        ecobackend.json_benefits_call = mockbenefits
开发者ID:PyBulls,项目名称:OTM2,代码行数:55,代码来源:ecobenefits.py


示例12: _process_record

    def _process_record(self, rec):
        pk = rec['pk']
        fields = rec['fields']

        fields['max_height'] = fields['v_max_height'] or 10000
        del fields['v_max_height']

        fields['max_dbh'] = fields['v_max_dbh'] or 10000
        del fields['v_max_dbh']

        removed_fields = ['alternate_symbol', 'v_multiple_trunks',
                          'tree_count', 'resource', 'itree_code']

        for f in removed_fields:
            del fields[f]

        s = Species(**fields)
        s.pk = pk

        s.save()
开发者ID:balexandrowicz,项目名称:OTM2,代码行数:20,代码来源:load_species.py


示例13: test_like_filter

    def test_like_filter(self):
        species = Species(
            instance=self.instance,
            common_name='this is a test species',
            genus='Genus-1',
            otm_code='S1')
        species.save_with_user(self.commander)

        p, t = self.create_tree_and_plot()

        t.species = species
        t.save_with_user(self.commander)

        species_like_filter = json.dumps({
            'species.common_name':
            {'LIKE': 's a tes'}})

        result = [o.pk for o in
                  _execute_filter(
                      self.instance, species_like_filter)]

        self.assertEqual(result, [p.pk])

        species.common_name = 'no match'
        species.save_with_user(self.commander)

        result = _execute_filter(
            self.instance, species_like_filter)

        self.assertEqual(len(result), 0)
开发者ID:ahinz,项目名称:OpenTreeMap-cloud,代码行数:30,代码来源:search.py


示例14: test_species_diameter_and_height

    def test_species_diameter_and_height(self):
        s1_gsc = Species(instance=self.instance, genus='g1', species='s1',
                         cultivar='c1', max_height=30, max_diameter=19)
        s1_gs = Species(instance=self.instance, genus='g1', species='s1',
                        cultivar='', max_height=22, max_diameter=12)
        s1_gsc.save_with_system_user_bypass_auth()
        s1_gs.save_with_system_user_bypass_auth()

        row = {'point x': '16',
               'point y': '20',
               'genus': 'g1',
               'species': 's1',
               'diameter': '15',
               'tree height': '18'}

        i = self.mkrow(row)
        i.validate_row()

        self.assertHasError(i, errors.SPECIES_DBH_TOO_HIGH)
        self.assertNotHasError(i, errors.SPECIES_HEIGHT_TOO_HIGH)

        row['tree height'] = 25
        i = self.mkrow(row)
        i.validate_row()

        self.assertHasError(i, errors.SPECIES_DBH_TOO_HIGH)
        self.assertHasError(i, errors.SPECIES_HEIGHT_TOO_HIGH)

        row['cultivar'] = 'c1'
        i = self.mkrow(row)
        i.validate_row()

        self.assertNotHasError(i, errors.SPECIES_DBH_TOO_HIGH)
        self.assertNotHasError(i, errors.SPECIES_HEIGHT_TOO_HIGH)
开发者ID:ctaylo37,项目名称:OTM2,代码行数:34,代码来源:tests.py


示例15: test_like_filter

    def test_like_filter(self):
        species = Species(
            instance=self.instance,
            common_name='this is a test species',
            genus='Genus-1',
            otm_code='S1')
        species.save_with_user(self.commander)

        p, t = self.create_tree_and_plot()

        t.species = species
        t.save_with_user(self.commander)

        species_like_filter = json.dumps({
            'species.common_name':
            {'LIKE': 's a tes'}})

        plots = search.Filter(species_like_filter, '', self.instance)\
                      .get_objects(Plot)

        result = [o.pk for o in plots]

        self.assertEqual(result, [p.pk])

        species.common_name = 'no match'
        species.save_with_user(self.commander)

        plots = search.Filter(species_like_filter, '', self.instance)\
                      .get_objects(Plot)

        self.assertEqual(len(plots), 0)
开发者ID:barbaralluz,项目名称:otm-core,代码行数:31,代码来源:test_search.py


示例16: test_species_diameter_and_height

    def test_species_diameter_and_height(self):
        s1_gsc = Species(
            instance=self.instance, genus="g1", species="s1", cultivar="c1", max_height=30, max_diameter=19
        )
        s1_gs = Species(instance=self.instance, genus="g1", species="s1", cultivar="", max_height=22, max_diameter=12)
        s1_gsc.save_with_system_user_bypass_auth()
        s1_gs.save_with_system_user_bypass_auth()

        row = {"point x": "16", "point y": "20", "genus": "g1", "species": "s1", "diameter": "15", "tree height": "18"}

        i = self.mkrow(row)
        i.validate_row()

        self.assertHasError(i, errors.SPECIES_DBH_TOO_HIGH)
        self.assertNotHasError(i, errors.SPECIES_HEIGHT_TOO_HIGH)

        row["tree height"] = 25
        i = self.mkrow(row)
        i.validate_row()

        self.assertHasError(i, errors.SPECIES_DBH_TOO_HIGH)
        self.assertHasError(i, errors.SPECIES_HEIGHT_TOO_HIGH)

        row["cultivar"] = "c1"
        i = self.mkrow(row)
        i.validate_row()

        self.assertNotHasError(i, errors.SPECIES_DBH_TOO_HIGH)
        self.assertNotHasError(i, errors.SPECIES_HEIGHT_TOO_HIGH)
开发者ID:recklessromeo,项目名称:otm-core,代码行数:29,代码来源:tests.py


示例17: get_species

 def get_species(otm_code, region_code):
     species = Species.get_by_code(instance, otm_code, region_code)
     if species is None:
         raise Http404(
             "Could not find species with OTM code %s in instance %s"
             % (otm_code, instance.url_name))
     # The species may have been retrieved via an ITreeCodeOverride. In that
     # case, the species will not have an otm_code value and we need to set
     # it so it is available for the downstream code.
     if species.otm_code != otm_code:
         species.otm_code = otm_code
     print(species.common_name)
     return species
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:13,代码来源:views.py


示例18: test_tree_hash_to_model

    def test_tree_hash_to_model(self):
        test_plot = Plot(geom=Point(0, 0), instance=self.instance)
        test_plot.id = 95
        test_plot.save_with_user(self.commander)

        test_species = Species(instance=self.instance, otm_code="1",
                               common_name="asdfa", genus="sdfs")
        test_species.id = 85
        test_species.save_with_user(self.commander)

        tree_dict = json.loads(self.tree_blob)
        tree = hash_to_model(MIGRATION_RULES,
                             'tree', tree_dict, self.instance)
        tree.save_with_user(self.commander)
        tree = Tree.objects.get(pk=tree.pk)
        self.assertEqual(tree.plot, test_plot)
        self.assertEqual(tree.species, test_species)
        self.assertEqual(tree.readonly, True)
        self.assertEqual(tree.diameter, 0.2900001566)
        self.assertEqual(tree.canopy_height, None)
        self.assertEqual(tree.date_planted, None)
        self.assertEqual(tree.date_removed, None)
开发者ID:danmcginnis,项目名称:OTM2,代码行数:22,代码来源:tests.py


示例19: setUp

    def setUp(self):
        self.instance = make_instance(name='Test Instance')

        self.species = Species(instance=self.instance,
                               common_name='Test Common Name',
                               genus='Test Genus',
                               cultivar='Test Cultivar',
                               species='Test Species')
        self.species.save_base()

        self.user = make_user(username='commander', password='pw')

        self.import_event = ImportEvent(imported_by=self.user)
        self.import_event.save_base()

        self.plot = Plot(geom=Point(0, 0), instance=self.instance,
                         address_street="123 Main Street")

        self.plot.save_base()

        self.tree = Tree(plot=self.plot, instance=self.instance)

        self.tree.save_base()

        self.boundary = make_simple_boundary("Test Boundary")

        self.role = make_commander_role(self.instance)
        self.role.name = "Test Role"
        self.role.save()

        self.field_permission = FieldPermission(
            model_name="Tree",
            field_name="readonly",
            permission_level=FieldPermission.READ_ONLY,
            role=self.role,
            instance=self.instance)
        self.field_permission.save_base()

        self.audit = Audit(action=Audit.Type.Update,
                           model="Tree",
                           field="readonly",
                           model_id=1,
                           user=self.user,
                           previous_value=True,
                           current_value=False)
        self.audit.save_base()

        self.reputation_metric = ReputationMetric(instance=self.instance,
                                                  model_name="Tree",
                                                  action="Test Action")
        self.reputation_metric.save_base()
开发者ID:mmcfarland,项目名称:OTM2,代码行数:51,代码来源:models.py


示例20: test_species_matching

    def test_species_matching(self):
        csv = """
        | genus   | species    | common name | i-tree code  | usda symbol | alternative symbol | other part of scientific name |
        | testus1 | specieius1 | g1 s2 wowza | BDL_OTHER    |             |     |      |
        | genus   | blah       | common name | BDL_OTHER    | s1          |     |      |
        | testus1 | specieius1 | g1 s2 wowza | BDL_OTHER    | s2          |     |      |
        | testus2 | specieius2 | g1 s2 wowza | BDL_OTHER    | s1          | a3  |      |
        | genusN  | speciesN   | gN sN wowza | BDL_OTHER    |             |     | var3 |
        """

        j = self.run_through_process_views(csv)
        ierrors = self.extract_errors(j)

        # Errors for multiple species matches
        self.assertEqual(len(ierrors), 4)

        ie = SpeciesImportEvent.objects.get(pk=j['pk'])
        s1,s2,s3 = [s.pk for s in Species.objects.all()]

        s4s = Species(symbol='gnsn', scientific_name='',family='',
                      genus='genusN', species='speciesN', cultivar_name='',
                      other_part_of_name='var3', v_max_dbh=50.0, v_max_height=100.0)
        s4s.save()
        s4 = s4s.pk

        rows = ie.rows()
        matches = []
        for row in rows:
            row.validate_row()
            matches.append(row.cleaned[fields.species.ORIG_SPECIES])

        m1,m2,m3,m4,m5 = matches

        self.assertEqual(m1, {s1})
        self.assertEqual(m2, {s1})
        self.assertEqual(m3, {s1,s2})
        self.assertEqual(m4, {s1,s2,s3})
        self.assertEqual(m5, {s4})
开发者ID:OpenTreeMap,项目名称:otm-legacy,代码行数:38,代码来源:tests.py



注:本文中的treemap.models.Species类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Tree类代码示例发布时间:2022-05-27
下一篇:
Python models.Plot类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap