-
Notifications
You must be signed in to change notification settings - Fork 4
Add ability to configure explain command options #49
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
Changes from all commits
44a45f7
f47e9e6
e8de13c
b3f1e89
a7cf1b4
202d869
7fecb43
166e308
e8d6c31
6623e64
9d5d745
5e1f18b
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 |
---|---|---|
|
@@ -12,7 +12,6 @@ | |
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
import unittest | ||
import subprocess | ||
import os | ||
|
@@ -28,6 +27,7 @@ | |
class CommandLogger(monitoring.CommandListener): | ||
def __init__(self): | ||
self.cmd_payload = {} | ||
|
||
def started(self, event): | ||
self.cmd_payload = event.command | ||
|
||
|
@@ -37,6 +37,7 @@ def succeeded(self, event): | |
def failed(self, event): | ||
pass | ||
|
||
|
||
class TestExplainableCollection(unittest.TestCase): | ||
def setUp(self) -> None: | ||
self.logger = CommandLogger() | ||
|
@@ -217,6 +218,25 @@ def test_imports(self): | |
from pymongoexplain import ExplainableCollection | ||
self.assertEqual(ExplainableCollection, ExplainCollection) | ||
|
||
def test_verbosity(self): | ||
res = self.explain.find({}) | ||
self.assertNotIn("executionStats", res) | ||
self.assertNotIn("allPlansExecution", res.get("executionStats", [])) | ||
self.explain = ExplainCollection(self.collection, verbosity="executionStats") | ||
res = self.explain.find({}) | ||
self.assertIn("executionStats", res) | ||
self.assertNotIn("allPlansExecution", res["executionStats"]) | ||
self.explain = ExplainCollection(self.collection, verbosity="allPlansExecution") | ||
res = self.explain.find({}) | ||
self.assertIn("executionStats", res) | ||
self.assertIn("allPlansExecution", res["executionStats"]) | ||
|
||
def test_comment(self): | ||
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. Instead of checking the explain result, this test should probably assert that we sent the comment field with the explain comment using a CommandListener. 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. Done. |
||
self.explain.find({}) | ||
self.assertNotIn("comment", self.logger.cmd_payload) | ||
self.explain = ExplainCollection(self.collection, comment="comment") | ||
self.explain.find({}) | ||
self.assertIn("comment", self.logger.cmd_payload) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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 believe there needs to be a blank line after the code block.