-
-
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
Conversation
|
||
from snare.utils.snare_helpers import parse_timeout, str_to_bool | ||
|
||
|
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.
Remove extra line
self.v = None | ||
|
||
def test_parse_timeout(self): | ||
|
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.
Same here.
snare/tests/test_parse_timeout.py
Outdated
|
||
assert parse_timeout('24Y') == 86400 # Default 24H format is used. | ||
|
||
def test_str_to_bool(self): |
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 can be put separately.
snare/cloner.py
Outdated
@@ -19,7 +19,7 @@ def __init__(self, root, max_depth, css_validate): | |||
self.max_depth = max_depth | |||
self.moved_root = None | |||
if len(self.root.host) < 4: | |||
sys.exit('invalid taget {}'.format(self.root.host)) | |||
sys.exit('invalid target {}'.format(self.root.host)) |
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.
Make the PR focus on a certain task, please put it in a different PR.
snare/utils/snare_helpers.py
Outdated
@@ -63,12 +63,12 @@ def add_meta_tag(page_dir, index_page, config): | |||
main_page = main.read() | |||
soup = BeautifulSoup(main_page, 'html.parser') | |||
|
|||
if (google_content and soup.find("meta", attrs={"name": "google-site-verification"}) is None): | |||
if google_content and soup.find("meta", attrs={"name": "google-site-verification"}) is None: |
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.
Put it in a different PR and the rest too.
snare/utils/snare_helpers.py
Outdated
google_meta = soup.new_tag('meta') | ||
google_meta.attrs['name'] = 'google-site-verification' | ||
google_meta.attrs['content'] = google_content | ||
soup.head.append(google_meta) | ||
if (bing_content and soup.find("meta", attrs={"name": "msvalidate.01"}) is None): | ||
if bing_content and soup.find("meta", attrs={"name": "msvalidate.01"}) is None: |
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.
Same here.
Okayy, Will do the changes asap! |
08d12f7
to
3a333cd
Compare
Updated the requested changes. |
@@ -28,5 +28,8 @@ def test_add_meta_tag(self): | |||
assert(soup.find("meta", attrs={"name": "google-site-verification"}) and | |||
soup.find("meta", attrs={"name": "msvalidate.01"})) | |||
|
|||
config['WEB-TOOLS'] = dict(google='', bing='') |
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.
snare/tests/test_str_to_bool.py
Outdated
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Same for this case. True
, False
and Error
separate.
snare/tests/test_parse_timeout.py
Outdated
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Can you write it as 20*60*60
? It will make more sense. And update the others too.
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.
Yes, makes more sense. Will do the changes
snare/tests/test_str_to_bool.py
Outdated
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 comment
The reason will be displayed to describe this comment to others. Learn more.
You are using self.v
for the previous two cases, do the same for this too.
Changes Done. |
snare/tests/test_parse_timeout.py
Outdated
def test_parse_timeout(self): | ||
assert parse_timeout('20H') == 20*60*60 | ||
assert parse_timeout('10M') == 10*60 | ||
assert parse_timeout('1D') == 1*86400 |
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.
24*60*60
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.
Yes, sorry about this.
Changes this PR proposes -
snare_helpers.py
to 100%. Overall coverage increased to 75%..coverage
is added to.gitignore
file.Refs - #187