-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
[master] Porting #52933 to master #54576
Changes from all commits
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 |
---|---|---|
|
@@ -117,6 +117,10 @@ def validate(config): | |
if 'files' not in _config: | ||
return False, 'Configuration for inotify beacon must include files.' | ||
else: | ||
if not isinstance(_config['files'], dict): | ||
return False, ('Configuration for inotify beacon invalid, ' | ||
'files must be a dict.') | ||
|
||
for path in _config.get('files'): | ||
|
||
if not isinstance(_config['files'][path], dict): | ||
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.
This error is not correct, it must be a dict of dicts (which this PR validates). |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,10 +39,33 @@ def setUp(self): | |
def tearDown(self): | ||
shutil.rmtree(self.tmpdir, ignore_errors=True) | ||
|
||
def test_non_list_config(self): | ||
config = {} | ||
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. Unnecessary variable, just pass |
||
|
||
ret = inotify.validate(config) | ||
|
||
self.assertEqual(ret, (False, 'Configuration for inotify beacon must' | ||
' be a list.')) | ||
|
||
def test_empty_config(self): | ||
config = [{}] | ||
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 as above. |
||
ret = inotify.beacon(config) | ||
self.assertEqual(ret, []) | ||
ret = inotify.validate(config) | ||
_expected = (False, 'Configuration for inotify beacon must include files.') | ||
self.assertEqual(ret, _expected) | ||
|
||
def test_files_none_config(self): | ||
config = [{'files': None}] | ||
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. I won't say same as above here, although we don't actually use |
||
ret = inotify.validate(config) | ||
_expected = (False, 'Configuration for inotify beacon invalid, ' | ||
'files must be a dict.') | ||
self.assertEqual(ret, _expected) | ||
|
||
def test_files_list_config(self): | ||
config = [{'files': [{u'/importantfile': {u'mask': [u'modify']}}]}] | ||
ret = inotify.validate(config) | ||
_expected = (False, 'Configuration for inotify beacon invalid, ' | ||
'files must be a dict.') | ||
self.assertEqual(ret, _expected) | ||
|
||
def test_file_open(self): | ||
path = os.path.realpath(__file__) | ||
|
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.
I would remove the above
else
and dedent this logic.