示例#1
0
    def test_population_source_file_blank(self):
        unit_count = Unit.objects.all().count()
        p = Population(source_file='')

        p.save()

        self.assertEqual(unit_count, Unit.objects.all().count())
示例#2
0
    def test_population_link(self):
        index = Unit.objects.count()
        p = Population(source_file='workspace/Population_Grid.xml')
        p.save()

        new_unit = p.unit_set.first()
        self.assertGreater( Unit.objects.count(), index, "No new Units were added")
        self.assertEqual( Unit.objects.get(id=new_unit.id)._population, p, "New Unit should link back to newest Population object")
示例#3
0
文件: tests.py 项目: NAVADMC/ADSM
    def test_save(self):
        result = Population()
        result.id = 2
        result.save()

        result = Population.objects.get()
        self.assertEqual(Population.objects.count(), 1)
        self.assertEqual(result.pk, 1)
示例#4
0
文件: tests.py 项目: NAVADMC/ADSM
    def test_population_link(self):
        from ScenarioCreator.tests.test_parser import POPULATION_FIXTURES
        index = Unit.objects.count()
        p = Population(source_file=POPULATION_FIXTURES + 'Population_Grid.xml')
        p.save()

        new_unit = p.unit_set.first()
        self.assertGreater( Unit.objects.count(), index, "No new Units were added")
        self.assertEqual( Unit.objects.get(id=new_unit.id)._population, p, "New Unit should link back to newest Population object")
示例#5
0
 def test_population_removes_itself_when_errors_occur(self):
     population_count = Population.objects.all().count()
     p = Population(source_file='Population_Grid.xml')
     with self.assertRaises(OSError):
         p.save()
     self.assertEqual(population_count, Population.objects.all().count())
示例#6
0
 def test_population_source_file_invalid(self):
     p = Population(source_file='Population_Grid.xml')
     with self.assertRaises(OSError):
         p.save()