Example #1
0
    def test_registered_succeed_register_params(self, _status):
        _status.side_effect = [
            ([], []),
            (["SLES/15.2/x86_64"], ["SLES/15.2/x86_64"]),
        ]

        opts_mock = {"test": False}
        salt_mock = {"suseconnect.register": MagicMock()}
        with patch.dict(suseconnect.__salt__, salt_mock), patch.dict(
            suseconnect.__opts__, opts_mock
        ):
            result = suseconnect.registered(
                "my_setup",
                "regcode",
                product="SLES/15.2/x86_64",
                email="*****@*****.**",
                url=None,
                root=None,
            )
            self.assertEqual(
                result,
                {
                    "name": "my_setup",
                    "result": True,
                    "changes": {"SLES/15.2/x86_64": True},
                    "comment": ["Product or module SLES/15.2/x86_64 registered"],
                },
            )
            salt_mock["suseconnect.register"].assert_called_with(
                "regcode",
                product="SLES/15.2/x86_64",
                email="*****@*****.**",
                url=None,
                root=None,
            )
Example #2
0
 def test_registered_named_product(self, _status):
     _status.return_value = (["SLES/15.2/x86_64"], ["SLES/15.2/x86_64"])
     result = suseconnect.registered("SLES/15.2/x86_64", "regcode")
     self.assertEqual(
         result,
         {
             "name": "SLES/15.2/x86_64",
             "result": True,
             "changes": {},
             "comment": ["Product or module SLES/15.2/x86_64 already registered"],
         },
     )
Example #3
0
    def test_registered_test(self, _status):
        _status.return_value = ([], [])

        opts_mock = {"test": True}
        with patch.dict(suseconnect.__opts__, opts_mock):
            result = suseconnect.registered("my_setup", "regcode")
            self.assertEqual(
                result,
                {
                    "name": "my_setup",
                    "result": None,
                    "changes": {"default": True},
                    "comment": ["Product or module default would be registered"],
                },
            )
Example #4
0
    def test_registered_fail_register_end(self, _status):
        _status.return_value = ([], [])

        opts_mock = {"test": False}
        salt_mock = {"suseconnect.register": MagicMock()}
        with patch.dict(suseconnect.__salt__, salt_mock), patch.dict(
            suseconnect.__opts__, opts_mock
        ):
            result = suseconnect.registered("my_setup", "regcode")
            self.assertEqual(
                result,
                {
                    "name": "my_setup",
                    "result": False,
                    "changes": {"default": True},
                    "comment": ["Product or module default failed to register"],
                },
            )
Example #5
0
    def test_registered_fail_register(self, _status):
        _status.return_value = ([], [])

        opts_mock = {"test": False}
        salt_mock = {
            "suseconnect.register": MagicMock(
                side_effect=CommandExecutionError("some error")
            )
        }
        with patch.dict(suseconnect.__salt__, salt_mock), patch.dict(
            suseconnect.__opts__, opts_mock
        ):
            result = suseconnect.registered("my_setup", "regcode")
            self.assertEqual(
                result,
                {
                    "name": "my_setup",
                    "result": False,
                    "changes": {},
                    "comment": ["Error registering default: some error"],
                },
            )