def test_execution_manager_with_restore(self):
        file_1 = os.path.join(self.test_folder_path, 'file_1')
        os.mknod(file_1)

        self.assertEqual(delete_command.delete([file_1]),
                         0,
                         msg="Execute command should return success code: 0.")

        self.paths = [
            os.path.join(user_config_manager.get_property('bin_path'),
                         os.path.basename(file_1))
        ]

        self.options.update({'mods': ['restore']})

        self.assertEqual(execution_manager.execute_command(
            self.paths, self.options),
                         0,
                         msg="Execute command should return success code: 0.")

        self.assertFalse(
            os.path.exists(
                os.path.join(user_config_manager.get_property('bin_path'),
                             os.path.basename(file_1))))
        self.assertEqual(len(bin_config_manager.get_property('history')), 0)
    def test_execution_manager_with_create_bin(self):
        new_bin_location = os.path.join(self.test_folder_path, 'new_bin')

        self.options.update({'mods': ['create_bin'], 'path': new_bin_location})
        self.assertEqual(execution_manager.execute_command(
            self.paths, self.options),
                         0,
                         msg="Execute command should return success code: 0.")
        self.assertEqual(user_config_manager.get_property('bin_path'),
                         new_bin_location)
        self.assertEqual(len(bin_config_manager.get_property('history')), 0)
Example #3
0
def main():
    """Main Controller function

    It's start point for script execution.
    Handles all command line arguments and run other functionality according
    to arguments

    """

    [paths, options] = argument_manager.parse_arguments()
    log_helper.setup(options)
    user_config_manager.setup(options)
    return execution_manager.execute_command(paths, options)
 def test_execution_manager_with_delete(self):
     file_1 = os.path.join(self.test_folder_path, 'file_1')
     os.mknod(file_1)
     self.assertTrue(os.path.exists(file_1))
     self.options.update({'mods': ['remove']})
     self.paths = [file_1]
     self.assertEqual(execution_manager.execute_command(
         self.paths, self.options),
                      0,
                      msg="Execute command should return success code: 0.")
     self.assertFalse(os.path.exists(file_1))
     self.assertEqual(len(bin_config_manager.get_property('history')), 1)
     self.assertEqual(
         bin_config_manager.history_get(
             os.path.basename(file_1))['src_dir'], os.path.dirname(file_1))
 def test_execution_manager_with_copy_bin(self):
     file_1 = os.path.join(self.test_folder_path, 'file_1')
     os.mknod(file_1)
     delete_command.delete([file_1])
     copy_bin_location = os.path.join(self.test_folder_path, 'copy_bin')
     self.options.update({'mods': ['copy_bin'], 'path': copy_bin_location})
     self.assertEqual(execution_manager.execute_command(
         self.paths, self.options),
                      0,
                      msg="Execute command should return success code: 0.")
     self.assertTrue(
         os.path.exists(
             os.path.join(self.test_bin_path, os.path.basename(file_1))))
     self.assertTrue(
         os.path.exists(
             os.path.join(copy_bin_location, os.path.basename(file_1))))
     self.assertEqual(user_config_manager.get_property('bin_path'),
                      self.test_bin_path)
    def test_execution_manager_with_move_bin(self):
        file_1 = os.path.join(self.test_folder_path, 'file_1')
        os.mknod(file_1)
        delete_command.delete([file_1])
        new_bin_location = os.path.join(self.test_folder_path, 'new_bin')

        self.options.update({'mods': ['move_bin'], 'path': new_bin_location})
        self.assertEqual(execution_manager.execute_command(
            self.paths, self.options),
                         0,
                         msg="Execute command should return success code: 0.")
        self.assertEqual(user_config_manager.get_property('bin_path'),
                         new_bin_location)
        self.assertTrue(
            os.path.exists(
                os.path.join(new_bin_location, os.path.basename(file_1))))
        self.assertEqual(
            bin_config_manager.history_get(
                os.path.basename(file_1))['src_dir'], os.path.dirname(file_1))