def test_load_infrastructure_with_fields(self): output = StringIO() structure = StructureFactory.create(name='structure') filename = os.path.join(os.path.dirname(__file__), 'data', 'signage.shp') InfrastructureFactory(name="name") call_command('loadinfrastructure', filename, '--infrastructure', type_field='label', name_field='name', condition_field='condition', structure_default='structure', description_field='descriptio', year_field='year', verbosity=1, stdout=output) self.assertIn('Infrastructures will be linked to %s' % structure, output.getvalue()) self.assertIn("InfrastructureType 'type' created", output.getvalue()) self.assertIn("Condition Type 'condition' created", output.getvalue()) value = Infrastructure.objects.all() names = [val.name for val in value] years = [val.implantation_year for val in value] self.assertIn('coucou', names) self.assertIn(2010, years) self.assertIn(2012, years) self.assertEquals(value.count(), 3)
def test_load_infrastructure(self): output = StringIO() structure = StructureFactory.create(name='structure') filename = os.path.join(os.path.dirname(__file__), 'data', 'signage.shp') building = InfrastructureFactory(name="name", implantation_year=2010) call_command('loadinfrastructure', filename, '--infrastructure', type_default='label', name_default='name', condition_default='condition', structure_default='structure', description_default='description', year_default=2010, verbosity=2, stdout=output) self.assertIn('Infrastructures will be linked to %s' % structure, output.getvalue()) self.assertIn('2 objects created.', output.getvalue()) value = Infrastructure.objects.all() self.assertEquals(building.name, value[1].name) self.assertEquals(building.implantation_year, value[1].implantation_year) self.assertEquals(value.count(), 3)
def test_update_same_eid(self): output = StringIO() filename = os.path.join(os.path.dirname(__file__), 'data', 'infrastructure.shp') InfrastructureFactory(name="name", eid="eid_2") call_command('loadinfrastructure', filename, eid_field='eid', type_default='label', name_default='name', verbosity=2, stdout=output) self.assertIn("Update : name with eid eid1", output.getvalue()) self.assertEqual(Infrastructure.objects.count(), 2)
def test_load_infrastructure(self): filename = os.path.join(os.path.dirname(__file__), 'data', 'signage.shp') building = InfrastructureFactory(name="name", implantation_year=2010) call_command('loadinfrastructure', filename, '--infrastructure', type_default='label', name_default='name', condition_default='condition', structure_default='structure', description_default='description', year_default=2010, verbosity=0) value = Infrastructure.objects.all() self.assertEquals(building.name, value[1].name) self.assertEquals(building.implantation_year, value[1].implantation_year) self.assertEquals(value.count(), 3)