-
Notifications
You must be signed in to change notification settings - Fork 23
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
Test nb_client module #136
Conversation
once id is re-added to NotebookSession's attributes readd thisbookstore/bookstore/client/tests/test_nb_client.py Lines 93 to 98 in 60249b2
This comment was generated by todo based on a
|
Codecov Report
@@ Coverage Diff @@
## master #136 +/- ##
==========================================
- Coverage 47.32% 46.09% -1.24%
==========================================
Files 11 11
Lines 374 384 +10
==========================================
Hits 177 177
- Misses 197 207 +10 |
Codecov Report
@@ Coverage Diff @@
## master #136 +/- ##
==========================================
+ Coverage 50.25% 68.6% +18.34%
==========================================
Files 11 10 -1
Lines 386 395 +9
==========================================
+ Hits 194 271 +77
+ Misses 192 124 -68 |
once id is re-added to NotebookSession's attributes readd thisbookstore/bookstore/client/tests/test_nb_client.py Lines 93 to 98 in 1c7a9b7
This comment was generated by todo based on a
|
There's always something super disappointing when you see a code coverage report for a testing PR that reports a drop in test coverage for some reason… I don't get it — the tests get picked up by pytest-cov locally:
|
once id is re-added to NotebookSession's attributes readd thisbookstore/bookstore/client/tests/test_nb_client.py Lines 93 to 98 in 0bf64ab
This comment was generated by todo based on a
|
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.
@mpacer the files are pretty small so I think it is fine to leave type and client together for now.
I would move the test files under the bookstore/tests/client
directory instead of keeping with client. It keeps the tests together.
It tends to be more common in tests to have assert actual expected
pattern though the opposite is technically valid. It's slightly more readable to do the first. For example:
assert extract_kernel_id(connection_file) == expected_kernel_id
would read from left to right as: If I test the extract_kernel_id function with a connection file, I would expect to receive this expected kernel id. It also makes it a bit easier for the reviewer to scan down the left of the page to see the commands executed.
@@ -0,0 +1,116 @@ | |||
import pytest |
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.
Consider moving the client tests to bookstore/tests/client/test_nb_client.py
so all tests are kept together.
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.
Sounds good
@@ -78,16 +78,29 @@ def __init__(self, *args, id, name, last_activity, execution_state, connections) | |||
def __repr__(self): | |||
return json.dumps(self.model, indent=2) | |||
|
|||
def __eq__(self, other): | |||
if isinstance(other, KernelInfo): |
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.
Good job checking the object is a KernelInfo instance.
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.
Thanks!
) | ||
|
||
|
||
@pytest.fixture |
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.
Consider moving all fixtures into their own file and importing that file. This makes the tests more visible and the test setup more reusable in other tests.
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.
Sounds good
|
||
|
||
def test_notebook_session_class(notebook_session, session_dict): | ||
# assert notebook_session.id == session_dict['id'] # TODO: once id is re-added to NotebookSession's attributes readd this |
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.
Let's remove the comments in this file and the other and instead open an issue to track.
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 created #135
], | ||
) | ||
def test_extract_kernel_id(connection_file, expected_kernel_id): | ||
assert expected_kernel_id == extract_kernel_id(connection_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.
Perhaps flip the assert statement. assert <test_result> <expected result>
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.
Sounds good
tox.ini
Outdated
@@ -73,7 +73,7 @@ deps = | |||
depends = | |||
py36: clean | |||
commands = | |||
pytest -v --maxfail=2 --cov-config=.coveragerc --cov=bookstore -W always bookstore/tests/ | |||
pytest -v --maxfail=2 --cov-config=.coveragerc --cov=bookstore -W always |
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 be inclined to leave the directory here and move the client tests to bookstore/tests/client/...
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.
Ok.
tox.ini
Outdated
@@ -73,7 +73,7 @@ deps = | |||
depends = | |||
py36: clean | |||
commands = | |||
pytest -v --maxfail=2 --cov-config=.coveragerc --cov=bookstore -W always bookstore/tests/ | |||
pytest -v --maxfail=2 --cov-config=.coveragerc --cov=bookstore -W always |
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 be inclined to leave the directory here and move the client tests to bookstore/tests/client/...
tox.ini
Outdated
@@ -73,7 +73,7 @@ deps = | |||
depends = | |||
py36: clean | |||
commands = | |||
pytest -v --maxfail=2 --cov-config=.coveragerc --cov=bookstore -W always bookstore/tests/ | |||
pytest -v --maxfail=2 --cov-config=.coveragerc --cov=bookstore -W always |
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 be inclined to leave the directory here and move the client tests to bookstore/tests/client/...
once id is re-added to NotebookSession's attributes readd thisbookstore/bookstore/client/tests/test_nb_client.py Lines 93 to 98 in f72a1bd
This comment was generated by todo based on a
|
1 similar comment
once id is re-added to NotebookSession's attributes readd thisbookstore/bookstore/client/tests/test_nb_client.py Lines 93 to 98 in f72a1bd
This comment was generated by todo based on a
|
- Also makes minor improvements to NotebookSession's deprecated notebook by providing a default argument in the case that the field is removed.
Co-Authored-By: Carol Willing <[email protected]>
Thank you for the reviews @willingc! I think I addressed them all, please let me know if not. |
Fantastic @mpacer. Happy to merge. |
This add unit tests for the record types and simple functions in nb_client.
It will either take some clever mocking or proper integration tests to properly handle the rest of the classes in this module.
Going through this made me wonder if we should split this module into an nb_types and and nb_client module… as this seemed to be a fairly clean delineation between the two types of functionality.