-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: monitor-only not being set properly when false/no passed in config #285
Changes from 3 commits
f74045f
481a369
6add5c7
6cd3f9c
afa87d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
from landscape.client.deployment import BaseConfiguration | ||
from landscape.client.deployment import Configuration | ||
from landscape.client.deployment import convert_arg_to_bool | ||
from landscape.client.deployment import generate_computer_title | ||
from landscape.client.deployment import get_versioned_persist | ||
from landscape.client.deployment import init_logging | ||
|
@@ -468,7 +469,7 @@ def test_generate_computer_title_wait_for_serial_no_serial_assertion( | |
) | ||
self.assertIsNone(title) | ||
mock_debug.assert_called_once_with( | ||
"No serial assertion in snap info {}, waiting..." | ||
"No serial assertion in snap info {}, waiting...", | ||
) | ||
|
||
@mock.patch("landscape.client.deployment.debug") | ||
|
@@ -601,3 +602,33 @@ def test_generate_computer_title_with_date( | |
}, | ||
) | ||
self.assertEqual(title, "2024-machine") | ||
|
||
|
||
class ArgConversionTest(LandscapeTest): | ||
"""Tests for `convert_arg_to_bool` function""" | ||
|
||
def test_true_values(self): | ||
TRUTHY_VALUES = {"true", "yes", "y", "1", "on", "TRUE", "Yes"} | ||
val = True | ||
for t in TRUTHY_VALUES: | ||
val = convert_arg_to_bool(t) | ||
self.assertTrue(val) | ||
|
||
def test_false_values(self): | ||
FALSY_VALUES = {"false", "no", "n", "0", "off", "FALSE", "No"} | ||
val = False | ||
for f in FALSY_VALUES: | ||
val = convert_arg_to_bool(f) | ||
self.assertFalse(val) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll want this in the loop - it's OK if the test fails after the first failing instance. We don't have to worry about subtests. You also won't need to initialize |
||
|
||
@mock.patch("landscape.client.deployment.info") | ||
def test_invalid_values(self, logging): | ||
INVALID_VALUES = {"invalid", "truthy", "2", "exit"} | ||
val = False | ||
for i in INVALID_VALUES: | ||
val = convert_arg_to_bool(i) | ||
logging.assert_called_with( | ||
"Error. Invalid boolean provided in config or parameters. " | ||
+ "Defaulting to False.", | ||
) | ||
self.assertFalse(val) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here