def test_get_from_file(self): office = Space(1, 'prooms', 1) d = office.get_from_file(r'data/prooms.txt') # check if the number list items equals number of lines ina file with open('data/prooms.txt') as f: total = sum(1 for _ in f) self.assertTrue(type(d), type([])) # check that the lit has equal number lines and self.assertTrue(len(d), total)
def test_allocate_room(self): office = Space(1, 'prooms') # check if dictionary has been created self.assertTrue(type(office.room_list), type({})) # check if number passed is corrected self.assertEqual(office.num_rooms, 1) # check if the list of room coincides with the number of rooms # generated self.assertEqual(len(office.room_list), 1) # check if naming convention is right and it exists self.assertTrue('prooms 0' in office.room_list.keys(), True) # check if the list created has empty list self.assertListEqual(office.room_list['prooms 0'], []) # allocate a room name = 'david' r_alloc = (office.allocate_room(name)) # check if name assigned is returned self.assertIn(name, r_alloc,) # remove test file os.remove(office.path)