-
-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
22 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,12 @@ | ||
import unittest | ||
from snare.utils.snare_helpers import parse_timeout, str_to_bool | ||
from snare.utils.snare_helpers import parse_timeout | ||
|
||
|
||
class TestParseTimeout(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.v = None | ||
|
||
def test_parse_timeout(self): | ||
|
||
assert parse_timeout('20H') == 72000 | ||
assert parse_timeout('10M') == 600 | ||
assert parse_timeout('1D') == 86400 | ||
|
||
assert parse_timeout('24Y') == 86400 # Default 24H format is used. | ||
|
||
def test_str_to_bool(self): | ||
|
||
self.v = 'true' | ||
assert str_to_bool(self.v) is True | ||
self.v = 'false' | ||
assert str_to_bool(self.v) is False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): | ||
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters