def test_load_extra_stop_shift_current(self): from objects import Extra_Stop from os import mkdir, path, remove, rmdir from processes.load import load_extra_stop extra_stop = Extra_Stop(self.shift) file_list = extra_stop.file_list() # create file mkdir(file_list['directory']) with open(file_list['location'], 'w') as location_file: location_file.write(self.shift.extra_stops[0].location) with open(file_list['reason'], 'w') as reason_file: reason_file.write(self.shift.extra_stops[0].reason) with open(file_list['miles_traveled'], 'w') as miles_traveled_file: miles_traveled_file.write( str(self.shift.extra_stops[0].miles_traveled)) with open(file_list['start_time'], 'w') as start_time_file: start_time_file.write(str(self.shift.extra_stops[0].start_time)) with open(file_list['end_time'], 'w') as end_time_file: end_time_file.write(str(self.shift.extra_stops[0].end_time)) # check that file was created and baseline self.assertTrue(path.exists(file_list['location'])) self.assertTrue(path.exists(file_list['reason'])) self.assertTrue(path.exists(file_list['miles_traveled'])) self.assertTrue(path.exists(file_list['start_time'])) self.assertTrue(path.exists(file_list['end_time'])) self.assertNotEqual(extra_stop.location, self.shift.extra_stops[0].location) self.assertNotEqual(extra_stop.reason, self.shift.extra_stops[0].reason) self.assertNotEqual(extra_stop.miles_traveled, self.shift.extra_stops[0].miles_traveled) self.assertNotEqual(extra_stop.start_time, self.shift.extra_stops[0].start_time) self.assertNotEqual(extra_stop.end_time, self.shift.extra_stops[0].end_time) # run function extra_stop = load_extra_stop(extra_stop, current=True) # check that data was loaded correctly self.assertEqual(extra_stop.location, self.shift.extra_stops[0].location) self.assertEqual(extra_stop.reason, self.shift.extra_stops[0].reason) self.assertEqual(extra_stop.miles_traveled, self.shift.extra_stops[0].miles_traveled) self.assertEqual(extra_stop.start_time, self.shift.extra_stops[0].start_time) self.assertEqual(extra_stop.end_time, self.shift.extra_stops[0].end_time) # delete file remove(file_list['location']) remove(file_list['reason']) remove(file_list['miles_traveled']) remove(file_list['start_time']) remove(file_list['end_time']) rmdir(file_list['directory'])
def test_load_extra_stop_shift_completed(self): from objects import Extra_Stop from os import remove, path from processes.load import load_extra_stop extra_stop = Extra_Stop(self.shift) file_list = extra_stop.file_list() # create file with open(file_list['info'], 'w') as info_file: info_file.write(self.shift.extra_stops[0].nlsv()) # check that file was created and baseline self.assertTrue(path.exists(file_list['info'])) self.assertNotEqual(extra_stop.location, self.shift.extra_stops[0].location) self.assertNotEqual(extra_stop.reason, self.shift.extra_stops[0].reason) self.assertNotEqual(extra_stop.miles_traveled, self.shift.extra_stops[0].miles_traveled) self.assertNotEqual(extra_stop.start_time, self.shift.extra_stops[0].start_time) self.assertNotEqual(extra_stop.end_time, self.shift.extra_stops[0].end_time) # run function extra_stop = load_extra_stop(extra_stop) # check that data was loaded correctly self.assertEqual(extra_stop.location, self.shift.extra_stops[0].location) self.assertEqual(extra_stop.reason, self.shift.extra_stops[0].reason) self.assertEqual(extra_stop.miles_traveled, self.shift.extra_stops[0].miles_traveled) self.assertEqual(extra_stop.start_time, self.shift.extra_stops[0].start_time) self.assertEqual(extra_stop.end_time, self.shift.extra_stops[0].end_time) # delete file remove(file_list['info'])
def test_load_extra_stop_delivery_completed(self): from objects import Extra_Stop from os import mkdir, path, rmdir, remove from processes.load import load_extra_stop delivery = self.shift.deliveries[1] extra_stop = Extra_Stop(delivery) file_list = extra_stop.file_list() # create file and directory mkdir(delivery.file_list()['directory']) with open(file_list['info'], 'w') as info_file: info_file.write(delivery.extra_stops[0].nlsv()) # check that file was created and baseline self.assertTrue(path.exists(file_list['info'])) self.assertNotEqual(extra_stop.location, delivery.extra_stops[0].location) self.assertNotEqual(extra_stop.reason, delivery.extra_stops[0].reason) self.assertNotEqual(extra_stop.miles_traveled, delivery.extra_stops[0].miles_traveled) self.assertNotEqual(extra_stop.end_time, delivery.extra_stops[0].end_time) # run function extra_stop = load_extra_stop(extra_stop) # check that data was loaded correctly self.assertEqual(extra_stop.location, delivery.extra_stops[0].location) self.assertEqual(extra_stop.reason, delivery.extra_stops[0].reason) self.assertEqual(extra_stop.miles_traveled, delivery.extra_stops[0].miles_traveled) self.assertEqual(extra_stop.end_time, delivery.extra_stops[0].end_time) # delete file remove(file_list['info']) rmdir(delivery.file_list()['directory'])
def load_current(self): from processes.load import load_extra_stop self = load_extra_stop(self) return self
def load_completed(self): from processes.load import load_extra_stop self.in_progress = False self = load_extra_stop(self) return self