コード例 #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)
コード例 #2
0
ファイル: office_tests.py プロジェクト: GDP254/a-21-project1
 def test_allocate_to_new_staff_space(self):
     office = Office("staff" + "Foin")
     staff = Staff("staff" + "Neritus", "staff" + "Otieno", "0784334537")
     result = len(allocations)
     office.allocate_to(staff)
     result_1 = len(allocations)
     self.assertEqual(result + 1, result_1)
コード例 #3
0
ファイル: office_tests.py プロジェクト: GDP254/a-21-project1
 def test_allocate_to_new_fellow_space(self):
     office = Office("staff" + "Foin")
     fellow = Fellow("staff" + "Neritus", "staff" + "Otieno", "0788934537",
                     "Y")
     result = len(allocations)
     office.allocate_to(fellow)
     result_1 = len(allocations)
     self.assertEqual(result + 1, result_1)
コード例 #4
0
ファイル: office_tests.py プロジェクト: GDP254/a-21-project1
 def test_arrogate_from_existing_staff(self):
     office = Office("staff" + 'Focs')
     staff = Staff("staff" + "Erits", "staff" + "Teno", "0785534224", "Y")
     office.allocate_to(staff)
     allocated_1 = office.has_allocation(staff)
     office.arrogate_from(staff)
     allocated_2 = office.has_allocation(staff)
     self.assertEqual([allocated_1, allocated_2], [True, False])
コード例 #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)
コード例 #6
0
ファイル: controller.py プロジェクト: GDP254/a-21-project1
def add_person(first_name, last_name, phone, type_, opt_in="N"):
    try:
        type_ = type_.upper()
        if type_ == "FELLOW":
            fellow = Fellow(first_name, last_name, phone, opt_in)
            fellow.register()
            first_name = fellow.first_name
            last_name = fellow.last_name
            type_ = fellow.type_
            available_offices = Office.available()
            if available_offices is False:
                print_pretty(" There are currently no available offices.")
            else:
                selection = random.choice(list(available_offices))
                office = Office(selection)
                office.allocate_to(fellow)
                print_pretty(
                    " The fellow: %s has been allocated to the office: %s." %
                    (fellow.last_name, office.name))
            if fellow.opt_in == "Y":
                available_livingspaces = LivingSpace.available()
                if available_livingspaces is False:
                    print_pretty(
                        " There are currently no available living spaces.")
                else:
                    selection = random.choice(list(available_livingspaces))
                    livingspace = LivingSpace(selection)
                    livingspace.allocate_to(fellow)
                    print_pretty(
                        " The fellow: %s has been allocated to the living space: %s."
                        % (fellow.last_name, livingspace.name))
            print_pretty(" A %s: %s %s has been successfully created." %
                         (type_, first_name, last_name))
        elif type_ == "STAFF":
            staff = Staff(first_name, last_name, phone, opt_in)
            staff.register()
            first_name = staff.first_name
            last_name = staff.last_name
            type_ = staff.type_
            available_offices = Office.available()
            if available_offices is False:
                print_pretty(" There are currently no available offices.")
            else:
                selection = random.choice(list(available_offices))
                office = Office(selection)
                office.allocate_to(staff)
                print_pretty(
                    " The staff: %s has been allocated to the office: %s." %
                    (staff.last_name, office.name))
            print_pretty(" A %s: %s %s has been successfully created." %
                         (type_, first_name, last_name))
        else:
            print_pretty(" %s is currently not a supported role." % type_)
        #print(persons_detail)
    except Exception as e:
        print_pretty(str(e))
コード例 #7
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])
コード例 #8
0
ファイル: print_tests.py プロジェクト: GDP254/a-21-project1
	def test_print_populated_room(self):
		self.clear_stores()
		office = Office("NDO")
		Dojo.add_room(office)
		fellow = Fellow("Xone", "Ndobile", "0856443334", "y")
		fellow.register()
		office.allocate_to(fellow)
		allocations = office.allocations()
		output = Room.members(allocations)
		self.assertEqual(output, " 0856443334, NDOBILE, XONE, FELLOW\n")
コード例 #9
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])
コード例 #10
0
ファイル: print_tests.py プロジェクト: GDP254/a-21-project1
	def test_print_existing_allocations_to_screen(self):
		self.clear_stores()
		office = Office("NDO2")
		Dojo.add_room(office)
		fellow = Fellow("Xone2", "Ndobile2", "0856443324", "y")
		fellow.register()
		office.allocate_to(fellow)
		allocations_ = Room.all_allocations()
		output = Room.members(allocations_, room_tag=True)
		expected_output = " NDO2-OFFICE, 0856443324, NDOBILE2, XONE2, FELLOW\n"
		self.assertEqual(output, expected_output)
コード例 #11
0
ファイル: office_tests.py プロジェクト: GDP254/a-21-project1
 def test_allocate_to_staff_no_space(self):
     office = Office("staff" + 'Focusp')
     with self.assertRaises(ValueError):
         x = 0
         while (x <= 5):
             suffix = str(x)
             staff = Staff("staff" + "Neris" + suffix,
                           "staff" + "Oten" + suffix, "078433448" + suffix,
                           "N")
             office.allocate_to(staff)
             x += 1
コード例 #12
0
ファイル: print_tests.py プロジェクト: GDP254/a-21-project1
	def test_print_existing_unallocated_to_screen(self):
		self.clear_stores()
		office = Office("NDO4")
		Dojo.add_room(office)
		fellow = Fellow("Xone4", "Ndobile4", "0856443354", "y")
		fellow.register()
		office.allocate_to(fellow)
		fellow = Fellow("Xone5", "Ndobile6", "0856443009", "n")
		fellow.register()
		office.allocate_to(fellow)
		fellow = Fellow("Xone3", "Ndobile3", "0856443344", "y")
		fellow.register()
		output = Room.all_unallocated_persons()
		expected_output = "0856443344, NDOBILE3, XONE3, FELLOW\n"
		self.assertEqual(output, expected_output)
コード例 #13
0
ファイル: print_tests.py プロジェクト: GDP254/a-21-project1
	def test_print_existing_allocations_to_default_file(self):
		self.clear_stores()
		office = Office("ND2")
		Dojo.add_room(office)
		fellow = Fellow("Xne2", "Ndoile2", "0868443324", "y")
		fellow.register()
		office.allocate_to(fellow)
		allocations_ = Room.all_allocations()
		expected_output = Room.members(allocations_, room_tag=True)
		Room.to_file(expected_output)
		path = "output/"
		f = open(path+"File.txt", "r")
		output = f.read() #"NDO2-Office, 0856443324, NDOBILE2, XONE2, FELLOW"
		f.close()
		self.assertEqual(expected_output, output)
コード例 #14
0
ファイル: print_tests.py プロジェクト: GDP254/a-21-project1
	def test_print_existing_allocations_to_specific_file(self):
		self.clear_stores()
		office = Office("ND88")
		Dojo.add_room(office)
		fellow = Fellow("Xne88", "Ndoile88", "086800000", "y")
		fellow.register()
		office.allocate_to(fellow)
		allocations_ = Room.all_allocations()
		expected_output = Room.members(allocations_, room_tag=True)
		file_name = office.name+"-Allocations"
		Room.to_file(expected_output, file_name)
		path = "output/"
		f = open(path+file_name+".txt", "r")
		output = f.read() 
		f.close()
		self.assertEqual(expected_output, output)
コード例 #15
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])
コード例 #16
0
ファイル: office_tests.py プロジェクト: GDP254/a-21-project1
 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"])
コード例 #17
0
ファイル: office_tests.py プロジェクト: GDP254/a-21-project1
 def test_allocate_to_existing_staff_space(self):
     office = Office("staff" + "Focuspo")
     staff = Staff("staff" + "Nerits", "staff" + "Oteno", "0784334222", "N")
     office.allocate_to(staff)
     with self.assertRaises(ValueError):
         office.allocate_to(staff)