-
Notifications
You must be signed in to change notification settings - Fork 160
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
Added Tests for class PathStore in lib/path_store.py #214
Conversation
@kormat Ready for review |
ntools.eq_(pth_str.best_paths_history, "best_paths_history") | ||
|
||
|
||
class TestPathStoreInit(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.
This name is a duplicate
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.
👍
class TestPathStoreInit(object): | ||
""" | ||
Unit tests for lib.path_store.PathStore.__init__ | ||
""" |
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.
Need a test for when check_filters
returns False
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.
Oops, i missed test_filters
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.
👍
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.
There is one for when check_filters return false "test_filters"
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.
👍
pcb = MagicMock(spec_set=['get_n_hops']) | ||
pcb.get_n_hops.return_value = 2*i + 2 | ||
pth_str.candidates[i].pcb = pcb | ||
pth_str._update_all_hops_length() |
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.
Check that get_n_hops
is called
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.
👍
def test_basic(self): | ||
pth_str = PathStore(self._setup()) | ||
pth_str.best_paths_history = [1] | ||
pth_str.best_paths_history[0] = [MagicMock(spec_set=['pcb']) |
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.
This is a bit weird. It would be simpler to just do:
pth_str.best_paths_history = []
pth_str.best_paths_history.append([MagicMock(spec_set=['pcb'] for i in range(5)])
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.
Fixed
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.
👍
@prateshg - there's ~5 lines missing from test coverage in this file. If this loads for you, you should be able to see them: https://circle-artifacts.com/gh/netsec-ethz/scion/613/artifacts/0/tmp/circle-artifacts.ylUPwNl/coverage/lib_path_store.html (it's taking ages for me). Otherwise run './scion.sh coverage lib_path_store_test' and then look at the html report that's linked at the bottom of the output. The affected code is not part of what you're testing here, so i'm happy for you to make a new PR to fix that, and i'll merge this one. |
I just looked at those 5 lines. The first 2 are because of the test generator that is used that I will fix. The next 3 are for except in (try/except) so I am not sure do I raise an exception for testing this? |
@kormat you can merge this |
Added Tests for class PathStore in lib/path_store.py
@prateshg - The test generator has a bug in it, and i'm surprised it didn't fail :( |
And yes, for |
Maybe we're looking at somewhere different, but https://github.com/netsec-ethz/scion/blob/master/test/lib_path_store_test.py#L200 just uses |
Ahh. The return of |
Added Tests for class PathStore in lib/path_store.py
The affected code is not part of what you're testing here, so i'm happy for you to make a new PR to fix that, and i'll merge this one.
pth_pol.property_ranges['GuaranteedBandwidth'].extend(range_)
should be:
pth_pol.property_ranges[key].extend(range_)
from_file
, you should use a test generator to raise all 3 exceptions.eq_
check_property_ranges
defaults toTrue
check_filters
returnsFalse
test_filters
get_n_peer_links()
was called on each candidate.get_n_hops
is calledget_timestamp
is calledsetUp
/tearDown
methods that aren't used by all test cases (and in fact whose work is partially duplicated by a test case) isn't a good approach. I would instead make a_setup
method like:(ping)