def test_get_systemd_only_platform(): """ Test the _get_system_only function on unsupported platforms """ def test_func(cats, dogs, no_block): pass with patch.object(service._get_systemd_only, "HAS_SYSTEMD", False, create=True): ret, warnings = service._get_systemd_only(test_func, { "cats": 1, "no_block": 2, "unmask": 3 }) assert warnings == [ "The 'no_block' argument is not supported by this platform" ] assert ret == {} ret, warnings = service._get_systemd_only(test_func, { "cats": 1, "unmask": 3 }) assert len(warnings) == 0 assert ret == {}
def test_get_systemd_only(): """ Test the _get_system_only function """ def test_func(cats, dogs, no_block): pass with patch.object(service._get_systemd_only, "HAS_SYSTEMD", True, create=True): ret, warnings = service._get_systemd_only(test_func, { "cats": 1, "no_block": 2, "unmask": 3 }) assert len(warnings) == 0 assert ret == {"no_block": 2} ret, warnings = service._get_systemd_only(test_func, { "cats": 1, "unmask": 3 }) assert len(warnings) == 0 assert ret == {}
def test_get_systemd_only(self): def test_func(cats, dogs, no_block): pass with patch.object(service._get_systemd_only, "HAS_SYSTEMD", True): ret, warnings = service._get_systemd_only(test_func, { "cats": 1, "no_block": 2, "unmask": 3 }) self.assertEqual(len(warnings), 0) self.assertEqual(ret, {"no_block": 2}) ret, warnings = service._get_systemd_only(test_func, { "cats": 1, "unmask": 3 }) self.assertEqual(len(warnings), 0) self.assertEqual(ret, {})
def test_get_systemd_only_no_mock(self): def test_func(cats, dogs, no_block): pass ret, warnings = service._get_systemd_only(test_func, { "cats": 1, "no_block": 2, "unmask": 3 }) self.assertIsInstance(ret, dict) self.assertIsInstance(warnings, list)
def test_get_systemd_only_no_mock(): """ Test the _get_system_only without mocking """ def test_func(cats, dogs, no_block): pass ret, warnings = service._get_systemd_only( test_func, {"cats": 1, "no_block": 2, "unmask": 3} ) assert isinstance(ret, dict) assert isinstance(warnings, list)
def test_get_systemd_only_platform(self): def test_func(cats, dogs, no_block): pass with patch.object(service._get_systemd_only, "HAS_SYSTEMD", False): ret, warnings = service._get_systemd_only(test_func, { "cats": 1, "no_block": 2, "unmask": 3 }) self.assertEqual( warnings, ["The 'no_block' argument is not supported by this platform"]) self.assertEqual(ret, {}) ret, warnings = service._get_systemd_only(test_func, { "cats": 1, "unmask": 3 }) self.assertEqual(len(warnings), 0) self.assertEqual(ret, {})