-
Notifications
You must be signed in to change notification settings - Fork 5
Conversation
This change adds a simple session interface and fake session class for use by tests in other modules that take a session object.
Review status: 0 of 2 files reviewed at latest revision, 9 unresolved discussions. site-packages/mlab/disco/simple_session.py, line 1 [r1] (raw file): site-packages/mlab/disco/simple_session.py, line 22 [r1] (raw file): site-packages/mlab/disco/simple_session.py, line 25 [r1] (raw file): If not, extraneous "a" after "containing" site-packages/mlab/disco/simple_session.py, line 57 [r1] (raw file): site-packages/mlab/disco/simple_session.py, line 59 [r1] (raw file): site-packages/mlab/disco/simple_session.py, line 64 [r1] (raw file): site-packages/mlab/disco/simple_session_test.py, line 14 [r1] (raw file): site-packages/mlab/disco/simple_session_test.py, line 39 [r1] (raw file): site-packages/mlab/disco/simple_session_test.py, line 52 [r1] (raw file): Comments from Reviewable |
Review status: 0 of 2 files reviewed at latest revision, 9 unresolved discussions. site-packages/mlab/disco/simple_session.py, line 1 [r1] (raw file): site-packages/mlab/disco/simple_session.py, line 22 [r1] (raw file): The two errors we care most about are:
netsnmp does appear to set ErrorStr for Timeout. So raising an exception for this case makes sense to me. I've added But, netsnmp reports nothing in ErrorStr for unknown or missing OIDs. And, the behavior for While a VarList is passed to both get and walk, the contents of the list changes after a call to My thinking was to make the error case for get and walk look the same from the caller's perspective, i.e. an empty list. Since netsnmp doesn't set ErrorStr for this case, I'm didn't think raising an exception would be as helpful to the caller. What do you think? What would be more helpful? site-packages/mlab/disco/simple_session.py, line 25 [r1] (raw file): Can you say more about the value of a custom class over dict? site-packages/mlab/disco/simple_session.py, line 57 [r1] (raw file): My best understanding right now is that "mib" is analogous to "database" and "oid" is analogous to "index to a row of database". I've updated the instance variable to site-packages/mlab/disco/simple_session.py, line 59 [r1] (raw file): site-packages/mlab/disco/simple_session.py, line 64 [r1] (raw file): site-packages/mlab/disco/simple_session_test.py, line 14 [r1] (raw file): site-packages/mlab/disco/simple_session_test.py, line 39 [r1] (raw file): site-packages/mlab/disco/simple_session_test.py, line 52 [r1] (raw file): Comments from Reviewable |
Review status: 0 of 2 files reviewed at latest revision, 5 unresolved discussions. site-packages/mlab/disco/simple_session.py, line 22 [r1] (raw file): site-packages/mlab/disco/simple_session.py, line 25 [r1] (raw file): I understand that we're violating encapsulation by using site-packages/mlab/disco/simple_session.py, line 73 [r2] (raw file):
https://google.github.io/styleguide/pyguide.html?showone=List_Comprehensions#List_Comprehensions site-packages/mlab/disco/simple_session_test.py, line 14 [r2] (raw file): site-packages/mlab/disco/simple_session_test.py, line 28 [r2] (raw file): Comments from Reviewable |
Review status: 0 of 2 files reviewed at latest revision, 5 unresolved discussions, some commit checks failed. site-packages/mlab/disco/simple_session.py, line 22 [r1] (raw file): Sometimes there is more context at the call site than within the called function, which is helpful for logging or error reporting. But, in these cases, I think it's okay to raise the exception here. site-packages/mlab/disco/simple_session.py, line 25 [r1] (raw file): So, maybe in the spirit of creating a minimal interface that looks like the one we actually want, I've added an How does it look? site-packages/mlab/disco/simple_session.py, line 73 [r2] (raw file): site-packages/mlab/disco/simple_session_test.py, line 14 [r2] (raw file): site-packages/mlab/disco/simple_session_test.py, line 28 [r2] (raw file): This is a case when the mock patches interfere with the test arrange block. If we call netsnmp.Varbind within a test then we're calling the mocked version. Options I see to move the var_list definition closer to its use:
What do you think? Comments from Reviewable |
Reviewed 2 of 2 files at r3. site-packages/mlab/disco/simple_session.py, line 25 [r1] (raw file): site-packages/mlab/disco/simple_session_test.py, line 28 [r2] (raw file): I think the current mocking actually tests implementation details rather than interfaces. For example, we're asserting this:
because our implementation is like this:
But my reading of Varbind is that the following implementation is also valid, but would break our tests:
If we abstain from mocking these types, we don't run into that issue. Those types don't define equality operators, so we might need to define custom Comments from Reviewable |
Review status: 1 of 2 files reviewed at latest revision, 1 unresolved discussion. site-packages/mlab/disco/simple_session_test.py, line 28 [r2] (raw file): Because It turns out we can redefine the How does it look now? Comments from Reviewable |
Review status: 1 of 2 files reviewed at latest revision, 1 unresolved discussion. site-packages/mlab/disco/simple_session_test.py, line 28 [r2] (raw file): Comments from Reviewable |
Reviewed 1 of 1 files at r5. Comments from Reviewable |
Review status: all files reviewed at latest revision, 1 unresolved discussion, all commit checks successful. site-packages/mlab/disco/simple_session_test.py, line 28 [r2] (raw file): Comments from Reviewable |
This change adds a simple session class that simplifies the interface to netsnmp.Session. As well, this change adds a fake session class for use in tests in other modules that take a session object.
This change is