Example #1
0
 def test_environmental(self):
     from dplace_app.load.environmental import (
         load_environmental_var, load_environmental,
     )
     res = load_environmental([self.get_dict(Source='EA')])
     self.assertEqual(res, 0)
     res = load_environmental_var(csv_dict_reader(data_path('envvariables.csv')))
     self.assertEqual(res, 3)
     row_dict = self.get_dict(
         dataset='EA',
         soc_id='EA12',
         xd_id='xd1',
         soc_name='Example EA Society',
         alternate_names='Example',
         main_focal_year='2016')
     load_societies([row_dict])
     res = load_environmental([self.get_dict(**{
         'Source': 'EA',
         'soc_ID': 'EA12',
         'AnnualMeanTemperature': 1,
         'AnnualTemperatureVariance': 1,
         'longitude': 1,
         'latitude': 1,
     })])
     self.assertEqual(res, 1)
Example #2
0
    def test_load_trees(self):
        iso = ISOCode.objects.create(iso_code='abc')
        lang = Language.objects.create(glotto_code='ubyk1235',
                                       name='Ubykh',
                                       iso_code=iso)
        lang.save()
        load_societies(csv_dict_reader(data_path('societies.csv')))
        society = Society.objects.create(ext_id='455',
                                         xd_id='xd455',
                                         name='test',
                                         language=lang)
        society.save()
        res = load_trees(data_path())
        self.assertEqual(res, 2)
        sequences = tree_names(data_path())
        #labels should be created for the 5 societies in the semitic tree in societies.csv, plus the test society above
        self.assertEqual(sequences, 6)

        tree = LanguageTree.objects.filter(
            name='Abkhaz-Adyge.glotto.trees').first()
        label = LanguageTreeLabels.objects.filter(label='ubyk1235').first()
        self.assertIn(label, tree.taxa.all())
        self.assertIn(society, label.societies.all())

        tree = LanguageTree.objects.filter(name='semitic.trees').first()
        labels = LanguageTreeLabels.objects.filter(label='Amharic').first()
        self.assertEqual(tree.taxa.count(), 25)
        self.assertEqual(labels.societies.count(), 3)
        self.assertEqual(
            labels.societies.all().order_by(
                '-languagetreelabelssequence__fixed_order').first().ext_id,
            'Ca7')
        # existing trees are not recreated:
        self.assertEqual(load_trees(data_path()), 0)
Example #3
0
 def test_load_trees(self):
     iso = ISOCode.objects.create(iso_code='abc')
     lang = Language.objects.create(glotto_code='ubyk1235', name='Ubykh', iso_code=iso)
     lang.save()
     load_societies(csv_dict_reader(data_path('societies.csv')))
     society = Society.objects.create(
         ext_id = '455',
         xd_id = 'xd455',
         name = 'test',
         language=lang
     )
     society.save()
     res = load_trees(data_path())
     self.assertEqual(res, 2)
     sequences = tree_names(data_path())
     #labels should be created for the 5 societies in the semitic tree in societies.csv, plus the test society above
     self.assertEqual(sequences, 6)
     
     tree = LanguageTree.objects.filter(name='Abkhaz-Adyge.glotto.trees').first()
     label = LanguageTreeLabels.objects.filter(label='ubyk1235').first()
     self.assertIn(label, tree.taxa.all())
     self.assertIn(society, label.societies.all())
     
     tree = LanguageTree.objects.filter(name='semitic.trees').first()
     labels = LanguageTreeLabels.objects.filter(label='Amharic').first()
     self.assertEqual(tree.taxa.count(), 25)
     self.assertEqual(labels.societies.count(), 3)
     self.assertEqual(labels.societies.all().order_by('-languagetreelabelssequence__fixed_order').first().ext_id, 'Ca7')
     # existing trees are not recreated:
     self.assertEqual(load_trees(data_path()), 0)
Example #4
0
 def test_environmental(self):
     from dplace_app.load.environmental import (
         load_environmental_var, load_environmental,
     )
     res = load_environmental([self.get_dict(Dataset='EA')])
     self.assertEqual(res, 0)
     res = load_environmental_var(csv_dict_reader(data_path('envvariables.csv')))
     self.assertEqual(res, 3)
     load_societies(csv_dict_reader(data_path('societies.csv')))
     res = load_environmental(csv_dict_reader(data_path('envdata.csv')))
     self.assertEqual(res, 2)
Example #5
0
 def test_environmental(self):
     from dplace_app.load.environmental import (
         load_environmental_var,
         load_environmental,
     )
     res = load_environmental([self.get_dict(Dataset='EA')])
     self.assertEqual(res, 0)
     res = load_environmental_var(
         csv_dict_reader(data_path('envvariables.csv')))
     self.assertEqual(res, 3)
     load_societies(csv_dict_reader(data_path('societies.csv')))
     res = load_environmental(csv_dict_reader(data_path('envdata.csv')))
     self.assertEqual(res, 2)
Example #6
0
 def test_load_society(self):
     def society(dataset):
         return self.get_dict(
             dataset=dataset,
             soc_id='EA12' + dataset,
             xd_id='xd1',
             soc_name='Example Society',
             alternate_names='Example',
             main_focal_year='2016')
     self.assertEqual(load_societies([society('EA'), society('LRB'), society('x')]), 2)
Example #7
0
 def test_load_society(self):
     def society(dataset):
         return self.get_dict(
             dataset=dataset,
             soc_id='EA12' + dataset,
             xd_id='xd1',
             soc_name='Example Society',
             alternate_names='Example',
             original_name='Example 1',
             hraf_link='Example (EX1)',
             chirila_link='Example (1)',
             main_focal_year='2016')
     self.assertEqual(load_societies([society('EA'), society('Binford')]), 2)
     self.assertRaises(ValueError, load_societies, [society('x')])
Example #8
0
    def test_environmental(self):
        from dplace_app.load.environmental import (
            create_environmental_variables, load_environmental,
        )

        res = load_environmental([self.get_dict(Source='EA')])
        self.assertEqual(res, 0)
        row_dict = self.get_dict(
            dataset='EA',
            soc_id='EA12',
            xd_id='xd1',
            soc_name='Example EA Society',
            alternate_names='Example',
            main_focal_year='2016')
        load_societies([row_dict])
        res = load_environmental([self.get_dict(**{
            'Source': 'EA',
            'ID': 'EA12',
            'Orig.longitude': 1,
            'Orig.latitude': 1,
            'longitude': 1,
            'latitude': 1,
        })])
        self.assertEqual(res, 1)
Example #9
0
    def test_load_society(self):
        def society(dataset):
            return self.get_dict(dataset=dataset,
                                 soc_id='EA12' + dataset,
                                 xd_id='xd1',
                                 soc_name='Example Society',
                                 alternate_names='Example',
                                 original_name='Example 1',
                                 hraf_link='Example (EX1)',
                                 chirila_link='Example (1)',
                                 main_focal_year='2016')

        self.assertEqual(load_societies([society('EA'),
                                         society('Binford')]), 2)
        self.assertRaises(ValueError, load_societies, [society('x')])
Example #10
0
 def test_load_society_locations(self):
     load_regions(data_path('test_geo.json'))
     load_societies(csv_dict_reader(data_path('societies.csv')))
     res = society_locations(csv_dict_reader(data_path('society_locations.csv')))
Example #11
0
 def test_load_society_locations(self):
     load_regions(data_path('regions.geojson'))
     load_societies(csv_dict_reader(data_path('societies.csv')))
     society_locations(csv_dict_reader(data_path('society_locations.csv')))