-
-
Notifications
You must be signed in to change notification settings - Fork 136
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 coverage increased #188
Changes from 2 commits
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
.coverage | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import unittest | ||
from snare.utils.snare_helpers import parse_timeout | ||
|
||
|
||
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. Remove extra line |
||
class TestParseTimeout(unittest.TestCase): | ||
|
||
def test_parse_timeout(self): | ||
assert parse_timeout('20H') == 72000 | ||
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. Can you write it as 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. Yes, makes more sense. Will do the changes |
||
assert parse_timeout('10M') == 600 | ||
assert parse_timeout('1D') == 86400 | ||
|
||
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. Same here. |
||
assert parse_timeout('24Y') == 86400 # Default 24H format is used. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import unittest | ||
from argparse import ArgumentTypeError | ||
from snare.utils.snare_helpers import str_to_bool | ||
|
||
|
||
class TestStrToBool(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.v = None | ||
|
||
def test_str_to_bool(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. Same for this case. |
||
self.v = 'true' | ||
assert str_to_bool(self.v) is True | ||
self.v = 'false' | ||
assert str_to_bool(self.v) is False | ||
|
||
with self.assertRaises(ArgumentTypeError): | ||
str_to_bool('twz') | ||
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. You are using |
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.
Usually, different input conditions for a method are tested using separate test methods, so you can have a method name like
test_add_meta_tag_with_empty_tags
or anything else.