Example #1
0
    def test_return_tuple_of_given_resource_set_list_and_options(
            self, res_sets, options):
        res_sets.return_value = [{"ids": "A"}]
        options.return_value = 'O'

        self.assertEqual(([{
            "ids": "A"
        }], "O"), prepare_set_args(['A', 'b=c', "setoptions", "d=e"]))
Example #2
0
    def test_return_tuple_of_given_resource_set_list_and_options(
        self, res_sets, options
    ):
        res_sets.return_value = [{"ids": "A"}]
        options.return_value = 'O'

        self.assertEqual(
            ([{"ids": "A"}], "O"),
            prepare_set_args(['A', 'b=c', "setoptions", "d=e"])
        )
Example #3
0
def create_with_set(create_with_set_library_call, argv, modificators):
    """
    callable create_with_set_library_call create constraint with set
    list argv part of comandline args
        see usage for  "constraint (colocation|resource|ticket) set"
    dict like object modificators can contain
        "force" allows resource in clone/master and constraint duplicity
        "autocorrect" allows correct resource to its clone/master parent
    """
    resource_set_list, constraint_options = parse_args.prepare_set_args(argv)
    create_with_set_library_call(
        resource_set_list, constraint_options,
        can_repair_to_clone=modificators["autocorrect"],
        resource_in_clone_alowed=modificators["force"],
        duplication_alowed=modificators["force"],
    )
Example #4
0
def create_with_set(create_with_set_library_call, argv, modificators):
    """
    callable create_with_set_library_call create constraint with set
    list argv part of comandline args
        see usage for  "constraint (colocation|resource|ticket) set"
    dict like object modificators can contain
        "force" allows resource in clone/master and constraint duplicity
        "autocorrect" allows correct resource to its clone/master parent
    """
    resource_set_list, constraint_options = parse_args.prepare_set_args(argv)
    create_with_set_library_call(
        resource_set_list, constraint_options,
        can_repair_to_clone=modificators["autocorrect"],
        resource_in_clone_alowed=modificators["force"],
        duplication_alowed=modificators["force"],
    )
Example #5
0
def create_with_set(create_with_set_library_call, argv, modifiers):
    """
    callable create_with_set_library_call create constraint with set
    list argv part of comandline args
        see usage for  "constraint (colocation|resource|ticket) set"
    dict like object modifiers can contain
        "force" allows resource in clone/master and constraint duplicity

    Commandline options:
      * --force - allow resource inside clone (or master), allow duplicate
        element
      * -f - CIB file
    """
    resource_set_list, constraint_options = parse_args.prepare_set_args(argv)
    create_with_set_library_call(
        resource_set_list, constraint_options,
        resource_in_clone_alowed=modifiers.get("--force"),
        duplication_alowed=modifiers.get("--force"),
    )
Example #6
0
 def test_raises_when_setoption_more_than_once(self, res_sets, options):
     self.assertRaises(CmdLineInputError, lambda: prepare_set_args(
         ['A', 'b=c', 'setoptions', "c=d", "setoptions", "e=f"]
     ))
Example #7
0
 def test_raises_when_no_resource_in_set(self, res_sets, options):
     res_sets.return_value = [{"ids": [], "options": {"b": "c"}}]
     self.assertRaises(CmdLineInputError, lambda: prepare_set_args(["b=c"]))
     res_sets.assert_called_once_with(["b=c"])
Example #8
0
 def test_raises_when_no_set_specified(self, res_sets, options):
     self.assertRaises(CmdLineInputError, lambda: prepare_set_args([]))
     res_sets.assert_not_called()
Example #9
0
 def test_right_distribute_args_with_empty_options(self, res_sets, options):
     prepare_set_args(['A', 'b=c', 'setoptions'])
     res_sets.assert_called_once_with(['A', 'b=c'])
     options.assert_not_called()
Example #10
0
 def test_right_distribute_full_args(self, res_sets, options):
     prepare_set_args(['A', 'b=c', "setoptions", "d=e"])
     res_sets.assert_called_once_with(['A', 'b=c'])
     options.assert_called_once_with(["d=e"])
Example #11
0
 def test_right_distribute_args_with_empty_options(self, res_sets, options):
     prepare_set_args(["A", "b=c", "setoptions"])
     res_sets.assert_called_once_with(["A", "b=c"])
     options.assert_not_called()