Esempio n. 1
0
    def test_load_split_completed(self):
        from objects import Split
        from os import remove, path
        from processes.load import load_split

        split = Split(self.shift)
        file_list = split.file_list()

        # create file
        with open(file_list['info'], 'w') as info_file:
            info_file.write(self.shift.split.csv())

        # check file was created and baseline
        self.assertTrue(path.exists(file_list['info']))
        self.assertNotEqual(split.miles_traveled,
                            self.shift.split.miles_traveled)
        self.assertNotEqual(split.start_time, self.shift.split.start_time)
        self.assertNotEqual(split.end_time, self.shift.split.end_time)

        # run function
        split = load_split(split)

        # check that data was loaded correctly
        self.assertEqual(split.miles_traveled, self.shift.split.miles_traveled)
        self.assertEqual(split.start_time, self.shift.split.start_time)
        self.assertEqual(split.end_time, self.shift.split.end_time)

        # delete files and directories
        remove(file_list['info'])
    def load_completed(self):
        from processes.load import load_shift, load_carry_out_tips,\
            load_shift_deliveries, load_parent_extra_stops, load_split
        from os import path

        self.in_progress = False
        self = load_shift(self)
        if path.exists(self.file_list()['tips']):
            self = load_carry_out_tips(self)
        if path.exists(Delivery(self).file_list()['completed_ids']):
            self = load_shift_deliveries(self)
        if path.exists(Extra_Stop(self).file_list()['completed_ids']):
            self = load_parent_extra_stops(self)
        if path.exists(Split(self).file_list()['info']):
            self.split = load_split(Split(self))
        return self
Esempio n. 3
0
    def test_load_split_currrent(self):
        from objects import Split
        from os import mkdir, remove, rmdir, path
        from processes.load import load_split

        split = Split(self.shift)
        file_list = split.file_list()

        # create file
        mkdir(file_list['directory'])
        with open(file_list['miles_traveled'], 'w') as info_file:
            info_file.write(str(self.shift.split.miles_traveled))
        with open(file_list['start_time'], 'w') as info_file:
            info_file.write(str(self.shift.split.start_time))
        with open(file_list['end_time'], 'w') as info_file:
            info_file.write(str(self.shift.split.end_time))

        # check file was created and baseline
        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(split.miles_traveled,
                            self.shift.split.miles_traveled)
        self.assertNotEqual(split.start_time, self.shift.split.start_time)
        self.assertNotEqual(split.end_time, self.shift.split.end_time)

        # run function
        split = load_split(split, current=True)

        # check that data was loaded correctly
        self.assertEqual(split.miles_traveled, self.shift.split.miles_traveled)
        self.assertEqual(split.start_time, self.shift.split.start_time)
        self.assertEqual(split.end_time, self.shift.split.end_time)

        # delete files and directories
        remove(file_list['miles_traveled'])
        remove(file_list['start_time'])
        remove(file_list['end_time'])
        rmdir(file_list['directory'])
 def load_current(self):
     from processes.load import load_split
     self = load_split(self)
     return self
 def load_completed(self):
     from processes.load import load_split
     self.in_progress = False
     self = load_split(self)
     return self