-
Notifications
You must be signed in to change notification settings - Fork 92
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
Some initial unit tests for mpathcount.py #500
Some initial unit tests for mpathcount.py #500
Conversation
Signed-off-by: Tim Smith <tim.smith@citrix.com>
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.
generally looks good. A few minor niggles about using unittest asserts.
drivers/mpathcount.py
Outdated
@@ -24,6 +24,19 @@ | |||
import glob | |||
import json | |||
|
|||
supported = ['iscsi','lvmoiscsi','rawhba','lvmohba', 'ocfsohba', 'ocfsoiscsi', 'netapp','lvmofcoe', 'gfs2'] |
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.
missing space after netapp
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.
Was in the original. Will fix in the commit which moves it.
tests/test_mpathcount.py
Outdated
" `- 7:0:1:4 sdam 66:96 failed faulty running" | ||
] | ||
count, total = mpathcount.get_path_count('3600a098038303973743f486833396d44') | ||
assert(total == 4) |
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.
self.assertEqual(4, total, msg='XXX')
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.
Did these things. New version pushed
tests/test_mpathcount.py
Outdated
mpathcount.MAPPER_DIR = "test_support/fake_mapper" | ||
|
||
mpathcount.update_config("fred", "3600a098038303973743f486833396d44", "[2, 4]", remove, add, True) | ||
assert(store['MPPEnabled']) |
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.
self.assertIsNotNone(store['MPPEnabled'])
https://docs.python.org/3/library/unittest.html#assert-methods
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.
Did these things. New version pushed
Move some of the functionality of mpathcount.py into functions to make it a little easier to write unit tests for it Signed-off-by: Tim Smith <tim.smith@citrix.com>
ba3f674
to
0fd0bde
Compare
tests/test_mpathcount.py
Outdated
import SR | ||
import util | ||
|
||
#class FakeXapi(object): |
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.
Remove commented out code.
tests/test_mpathcount.py
Outdated
" `- 7:0:1:4 sdam 66:96 failed faulty running" | ||
] | ||
count, total = mpathcount.get_path_count('3600a098038303973743f486833396d44') | ||
self.assertEqual(4, total, msg='total should be 4, was {}'.format(total)) |
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.
the format is unnecessary, the unit test assert does all that anyway. Something like "Total count incorrect" is sufficient
Signed-off-by: Tim Smith <tim.smith@citrix.com>
0fd0bde
to
fb526db
Compare
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.
LGTM
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.
LGTM
No description provided.