Exemple #1
0
 def add_building(self, number, name="", bc=0):
     try:
         newBuilding = Building.objects.get(number=number)
         newBuilding.baseline_clients += bc
         if name != "" and newBuilding.name == "":
             newBuilding.name = name
     except Building.DoesNotExist:
         newBuilding = Building(name=name,
                                number=number,
                                baseline_clients=bc)
     newBuilding.save()
     return newBuilding
 def test_not_create_two_buildings_with_the_same_acronym_in_a_campus(self):
     building = Building()
     building.name = 'pantheone'
     building.acronym = 'Pan'
     building.phone = '(61) 3333-3332'
     building.campus = self.campus_01
     with self.assertRaises(ValidationError):
         building.save()
 def test_not_create_building_without_acronym(self):
     size = len(Building.objects.all())
     building = Building()
     building.phone = "(61) 3333-3333"
     building.name = 'UBC'
     building.campus = self.campus_01
     with self.assertRaises(ValidationError):
         building.save()
 def test_create_buildings_with_the_same_acronym_in_different_campi(self):
     size = len(Building.objects.all())
     building = Building()
     building.name = 'pantheone'
     building.acronym = 'Pan'
     building.phone = '(61) 3333-3332'
     building.campus = self.campus_02
     self.assertIsNone(building.save())
     self.assertEqual(size + 1, len(Building.objects.all()))
 def test_create_building(self):
     size = len(Building.objects.all())
     building = Building()
     building.name = 'ultimate building of chaos'
     building.phone = "(61) 3333-3333"
     building.acronym = 'UBC'
     building.campus = self.campus_01
     self.assertIsNone(building.save())
     self.assertEqual(size + 1, len(Building.objects.all()))
    def test_not_create_building_without_campus(self):
        size = len(Building.objects.all())

        building = Building()
        building.phone = 'Unlimited Blade Works'
        building.phone = "(61) 3333-3333"
        building.acronym = 'UBW'

        with self.assertRaises(ValidationError):
            building.save()
Exemple #7
0
#full path too djangoproject root
djangoproject_root = "/home/Ellis/CMPT470-1131-g-team-lazy/kotw/"

import sys,os
sys.path.append(djangoproject_root)
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

from buildings.models import Building
from governments.models import Government, effects
from military.models import Military
from techs.models import Tech

b=Building()
b.type="enterprise"
b.effect_name="increase income"
b.effect_val=0.6
b.save()

b=Building()
b.type="residence"
b.effect_name="increase max population"
b.effect_val=100.00
b.save()

b=Building()
b.type="industrial"
b.effect_name="decrease military training costs"
b.effect_val=0.65
b.save()

b=Building()
Exemple #8
0
#full path too djangoproject root
djangoproject_root = "/home/Ellis/CMPT470-1131-g-team-lazy/kotw/"

import sys, os

sys.path.append(djangoproject_root)
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

from buildings.models import Building
from governments.models import Government, effects
from military.models import Military
from techs.models import Tech

b = Building()
b.type = "enterprise"
b.effect_name = "increase income"
b.effect_val = 0.6
b.save()

b = Building()
b.type = "residence"
b.effect_name = "increase max population"
b.effect_val = 100.00
b.save()

b = Building()
b.type = "industrial"
b.effect_name = "decrease military training costs"
b.effect_val = 0.65
b.save()