示例#1
0
 def test_table_layout_when_no_location_type_or_location_yet(self):
     LocationType.objects.all().delete()
     LocationTypeDetails.objects.all().delete()
     Location.objects.all().delete()
     ea_csv_layout = UploadEACSVLayoutHelper()
     self.assertEqual(
         [["No Location/LocationType added yet. Please add those first."]],
         ea_csv_layout.table_layout_example())
示例#2
0
class EAUploadCSVLayoutHelperTest(BaseTest):
    def setUp(self):
        country = LocationType.objects.create(name='Country', slug='country')
        uganda = Location.objects.create(name="Uganda", type=country)
        LocationTypeDetails.objects.create(country=uganda, location_type=country)

        region_type = LocationType.objects.create(name="Regiontype", slug="regiontype")
        district_type = LocationType.objects.create(name="Districttype", slug='districttype')
        county_type = LocationType.objects.create(name="Countytype", slug='countytype')
        parish_type = LocationType.objects.create(name="Parishtype", slug='parishtype')

        region = Location.objects.create(name="region1", type=region_type, tree_parent=uganda)
        district = Location.objects.create(name="district1", tree_parent=region, type=district_type)
        county_1 = Location.objects.create(name="county1", tree_parent=district, type=county_type)
        parish_1 = Location.objects.create(name="parish_1", tree_parent=county_1, type=parish_type)
        parish_1_b = Location.objects.create(name="parish_1b", tree_parent=county_1, type=parish_type)

        region = Location.objects.create(name="region2", tree_parent=uganda, type=region_type)
        district = Location.objects.create(name="district2", tree_parent=region, type=district_type)
        county_2 = Location.objects.create(name="county2", tree_parent=district, type=county_type)
        parish_2 = Location.objects.create(name="parish_2", tree_parent=county_2, type=parish_type)

        self.ea_csv_layout = UploadEACSVLayoutHelper()

    def test_headers_format(self):
        expected_headers = ['Regiontype', 'Districttype', 'Countytype', 'EA', 'Parishtype', 'EA']
        [self.assertIn(header, expected_headers) for header in self.ea_csv_layout._header_format()]

    def test_table_layout_example(self):
       expected = [
                ['regiontype_0',    'districttype_0',    'countytype_0',   'ea_0', 'parishtype_0',   ''],
                ['regiontype_0',    'districttype_0',    'countytype_0',   'ea_0', 'parishtype_0_b',   ''],
                ['regiontype_1',    'districttype_1',    'countytype_1',   '', 'parishtype_1',   'ea_1'],
                ['regiontype_1',    'districttype_1',    'countytype_1',   '', 'parishtype_1',   'ea_1_b']]
       self.assertEqual(expected, self.ea_csv_layout.table_layout_example())

    def test_table_layout_when_no_location_type_or_location_yet(self):
        LocationType.objects.all().delete()
        LocationTypeDetails.objects.all().delete()
        Location.objects.all().delete()
        ea_csv_layout = UploadEACSVLayoutHelper()
        self.assertEqual([["No Location/LocationType added yet. Please add those first."]], ea_csv_layout.table_layout_example())
示例#3
0
 def test_table_layout_when_no_location_type_or_location_yet(self):
     LocationType.objects.all().delete()
     LocationTypeDetails.objects.all().delete()
     Location.objects.all().delete()
     ea_csv_layout = UploadEACSVLayoutHelper()
     self.assertEqual([["No Location/LocationType added yet. Please add those first."]], ea_csv_layout.table_layout_example())