Example #1
0
    def test_user_hash_to_model(self):
        user_dict = json.loads(self.user_blob)
        user = hash_to_model(MIGRATION_RULES, 'user', user_dict, self.instance)

        user.save_with_user(self.commander)

        user = User.objects.get(pk=user.pk)
        self.assertEqual(user.username, "kyle_reese")
        self.assertEqual(user.first_name, "Kyle")
        self.assertEqual(user.last_name, "Reese")
        self.assertEqual(user.email, "*****@*****.**")
        self.assertEqual(user.is_active, True)
        self.assertEqual(user.is_superuser, False)
        self.assertEqual(user.is_staff, False)
        self.assertEqual(user.groups.count(), 0)
        self.assertEqual(user.user_permissions.count(), 0)
Example #2
0
    def test_user_hash_to_model(self):
        user_dict = json.loads(self.user_blob)
        user = hash_to_model(MIGRATION_RULES,
                             'user', user_dict, self.instance)

        user.save_with_user(self.commander)

        user = User.objects.get(pk=user.pk)
        self.assertEqual(user.username, "kyle_reese")
        self.assertEqual(user.first_name, "Kyle")
        self.assertEqual(user.last_name, "Reese")
        self.assertEqual(user.email, "*****@*****.**")
        self.assertEqual(user.is_active, True)
        self.assertEqual(user.is_superuser, False)
        self.assertEqual(user.is_staff, False)
        self.assertEqual(user.groups.count(), 0)
        self.assertEqual(user.user_permissions.count(), 0)
Example #3
0
    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)

        tree_dict = json.loads(self.tree_blob)
        tree = hash_to_model('tree', tree_dict, self.instance,
                             self.commander)
        tree.save_with_user(self.commander)
        tree = Tree.objects.get(pk=tree.pk)
        self.assertEqual(tree.plot, test_plot)
        self.assertEqual(tree.species, None)
        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)
Example #4
0
 def test_plot_hash_to_model(self):
     plot_dict = json.loads(self.plot_blob)
     plot = hash_to_model(MIGRATION_RULES, 'plot', plot_dict, self.instance)
     # test that the plot geom is transformed as follows
     test_geom = copy(plot.geom)
     test_geom.transform(3857)
     plot.save_with_user(self.commander)
     plot = Plot.objects.get(pk=plot.pk)
     self.assertEqual(plot.owner_orig_id, '84368')
     self.assertEqual(plot.address_street, None)
     self.assertEqual(plot.address_zip, None)
     self.assertEqual(plot.width, 5.2)
     self.assertEqual(plot.readonly, True)
     self.assertEqual(plot.address_city, "123 Main Street")
     self.assertEqual(plot.geom.x, test_geom.x)
     self.assertEqual(plot.geom.y, test_geom.y)
     self.assertEqual(plot.length, 1.3)
Example #5
0
 def test_plot_hash_to_model(self):
     plot_dict = json.loads(self.plot_blob)
     plot = hash_to_model(MIGRATION_RULES,
                          'plot', plot_dict, self.instance)
     # test that the plot geom is transformed as follows
     test_geom = copy(plot.geom)
     test_geom.transform(3857)
     plot.save_with_user(self.commander)
     plot = Plot.objects.get(pk=plot.pk)
     self.assertEqual(plot.owner_orig_id, '84368')
     self.assertEqual(plot.address_street, None)
     self.assertEqual(plot.address_zip, None)
     self.assertEqual(plot.width, 5.2)
     self.assertEqual(plot.readonly, True)
     self.assertEqual(plot.address_city, "123 Main Street")
     self.assertEqual(plot.geom.x, test_geom.x)
     self.assertEqual(plot.geom.y, test_geom.y)
     self.assertEqual(plot.length, 1.3)
Example #6
0
    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)
Example #7
0
    def test_species_hash_to_model(self):
        species_dict = json.loads(self.species_blob)
        species = hash_to_model('species', species_dict,
                                self.instance, self.commander)

        species.save_with_user(self.commander)
        species = Species.objects.get(pk=species.pk)
        self.assertEqual(species.otm_code, 'SAVI')
        self.assertEqual(species.genus, 'Salix')
        self.assertEqual(species.species, 'viminalis')
        self.assertEqual(species.cultivar, '')
        self.assertEqual(species.gender, '')
        self.assertEqual(species.common_name, "Basket willow")
        self.assertEqual(species.native_status, 'False')
        self.assertEqual(species.bloom_period, None)
        self.assertEqual(species.fruit_period, None)
        self.assertEqual(species.fall_conspicuous, None)
        self.assertEqual(species.flower_conspicuous, None)
        self.assertEqual(species.palatable_human, None)
        self.assertEqual(species.wildlife_value, None)
        self.assertEqual(species.fact_sheet,
                         'http://eol.org/search?q=Salix viminalis')
        self.assertEqual(species.plant_guide, None)
Example #8
0
    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)