Example #1
0
	def test_reallocate_existing_staff_to_office(self):
		office = Office('My9994')
		Office.add(office)
		staff = Staff("Ugeg", "Insdnis", "073437")
		office.allocate_to(staff)
		with self.assertRaises(ValueError):
			Room.reallocate(staff, office)
Example #2
0
 def test_office_load_state(self):
     path = "db/"
     file_name = "mydb"
     file_ = file_name + ".db"
     #clean up to avoid conflict between tests
     os.remove(path + file_)
     self.clear_stores()
     #memory
     office1 = Office('ooskks9')
     Office.add(office1)
     Office.save_state(file_name)
     #db
     engine = create_engine("sqlite:///" + path + file_, echo=False)
     Session = sessionmaker(bind=engine)
     session = Session()
     db_office = session.query(Room).filter_by(
         roomname='ooskks9'.upper()).first()
     #clear memory stores
     self.clear_stores()
     #memory
     Office.load_state(file_name)
     office = Office.from_name('ooskks9')
     #compare
     full_office = [office.name, office.capacity, office.type_]
     full_db_office = [
         db_office.roomname, db_office.roomcapacity, db_office.roomtype
     ]
     session.close()
     self.assertEqual(full_db_office, full_office)
Example #3
0
def create_room(room_name, room_type):
    try:
        room_input_index = 0
        while room_input_index < len(room_name):
            room_type_curr = room_type[room_input_index].upper()
            room_name_curr = room_name[room_input_index].upper()
            if room_type_curr == "LIVINGSPACE":
                livingspace = LivingSpace(room_name_curr)
                LivingSpace.add(livingspace)
                print_pretty(
                    " A living space called %s has been successfully created."
                    % livingspace.name)
            elif room_type_curr == "OFFICE":
                office = Office(room_name_curr)
                Office.add(office)
                print_pretty(
                    " An office called %s has been successfully created." %
                    office.name)
            else:
                print_pretty(
                    " The specified room type %s, is currently not supported."
                    % room_type_curr)
            room_input_index += 1
    except Exception as e:
        print_pretty(str(e))
Example #4
0
	def test_instantiate_room_from_name(self):
		livingspace  = LivingSpace('MyLLLLL')
		LivingSpace.add(livingspace)
		office = Office('MyJJJSS')
		Office.add(office)
		livingspace1 = LivingSpace.from_name("MyLLLLL")
		office1 = Office.from_name("MyJJJSS")
		self.assertEqual(office.name, office1.name)
Example #5
0
	def test_reallocate_staff_to_livingspace(self):
		office = Office('M777848')
		Office.add(office)
		staff = Staff("jjjkkdsj", "liidsls", "0799034987")
		office.allocate_to(staff)
		livingspace1 = LivingSpace('U988934')
		LivingSpace.add(livingspace1)
		with self.assertRaises(Exception):
			Room.reallocate(staff, livingspace1)
Example #6
0
 def test_add_office(self):
     office = Office('MyOffice78')
     initial_room_count = len(Dojo.rooms())
     initial_office_count = len(Office.rooms())
     Office.add(office)
     new_room_count = len(Dojo.rooms())
     new_office_count = len(Office.rooms())
     self.assertEqual([initial_room_count + 1, initial_office_count + 1],
                      [new_room_count, new_office_count])
Example #7
0
	def test_reallocate_fellow_to_office(self):
		office = Office('000848')
		Office.add(office)
		fellow = Fellow("UNlsldg", "Ilslnis", "070555597537", "N")
		office.allocate_to(fellow)
		office1 = Office('M9498987')
		Office.add(office1)
		Room.reallocate(fellow, office1)
		self.assertEqual([office1.has_allocation(fellow), office.has_allocation(fellow)], 
						 [True, False])
Example #8
0
	def test_reallocate_staff_to_office(self):
		office = Office('Myok848')
		Office.add(office)
		staff = Staff("UNidng", "Inignis", "07089797537")
		office.allocate_to(staff)
		office1 = Office('M949438')
		Office.add(office1)
		Room.reallocate(staff, office1)
		self.assertEqual([office1.has_allocation(staff), office.has_allocation(staff)], 
						 [True, False])
Example #9
0
 def test_remove_office(self):
     office = Office('MyOffice89')
     Office.add(office)
     initial_room_count = len(Dojo.rooms())
     initial_office_count = len(Office.rooms())
     Office.remove(office)
     new_room_count = len(Dojo.rooms())
     new_office_count = len(Office.rooms())
     self.assertEqual([initial_room_count - 1, initial_office_count - 1],
                      [new_room_count, new_office_count])
Example #10
0
 def test_available_office(self):
     result = Office.available()
     office = Office('MyO55e89')
     Office.add(office)
     staff = Staff("staff" + "Njsiritus", "staff" + "Otsdeno", "0700000537")
     office.allocate_to(staff)
     staff = Staff("staff" + "Njsiritus", "staff" + "Otsdeno", "0700001537")
     office.allocate_to(staff)
     result_2 = Office.available()
     staff = Staff("staff" + "Njsiritus", "staff" + "Otsdeno", "0700002537")
     office.allocate_to(staff)
     staff = Staff("staff" + "Njsiritus", "staff" + "Otsdeno", "0700003537")
     office.allocate_to(staff)
     result_3 = Office.available()
     self.assertTrue([result, result_3, type(result_2)],
                     [False, False, "set"])
Example #11
0
	def test_reallocate_to_room_at_capacity(self):
		office = Office('0884oo848')
		Office.add(office)
		fellowx = Fellow("UNjlksd", "Ilnjndis", "070000345537", "N")
		office.allocate_to(fellowx)
		office1 = Office('M94llj87')
		Office.add(office1)
		fellow = Fellow("Usdsd", "Isdsds", "070015837", "N")
		office1.allocate_to(fellow)
		fellow = Fellow("rereed", "Iererds", "234235837", "N")
		office1.allocate_to(fellow)
		fellow = Fellow("Usdsdfsd", "Iskops", "079879787", "N")
		office1.allocate_to(fellow)
		fellow = Fellow("Uhoidfd", "Ioijfdsoids", "089437237", "N")
		office1.allocate_to(fellow)
		with self.assertRaises(ValueError):
			Room.reallocate(fellowx, office1)
		self.assertEqual([office1.has_allocation(fellowx), office.has_allocation(fellowx)], 
						 [False, True])
Example #12
0
 def test_add_an_existing_office(self):
     office = Office('MyOffice4545')
     Office.add(office)
     with self.assertRaises(ValueError):
         Office.add(office)