Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_getters(builtin_pkg):
req = build_req_tuple(
{'int': '1', 'empty_int': '', 'str': 'hello', 'empty_str': '', 'bool': 'true', 'float': '1.1'}
)
val = utils.get_str_arg(req, 'str')
assert isinstance(val, str) and val == 'hello'
val = utils.get_str_arg(req, 'str_def', default='def')
assert val == 'def'
val = utils.get_str_arg(req, 'empty_str')
assert val is None
with mock.patch('{}.str'.format(builtin_pkg), mock.Mock(side_effect=Exception)):
val = utils.get_str_arg(req, 'str', default='def')
assert val == 'def'
val = utils.get_int_arg(req, 'int')
assert isinstance(val, int) and val == 1
val = utils.get_int_arg(req, 'int_def', default=2)
assert val == 2
val = utils.get_int_arg(req, 'empty_int')
assert val is None
with mock.patch('{}.int'.format(builtin_pkg), mock.Mock(side_effect=Exception)):
val = utils.get_int_arg(req, 'int', default=2)
def test_getters(builtin_pkg):
req = build_req_tuple(
{'int': '1', 'empty_int': '', 'str': 'hello', 'empty_str': '', 'bool': 'true', 'float': '1.1'}
)
val = utils.get_str_arg(req, 'str')
assert isinstance(val, str) and val == 'hello'
val = utils.get_str_arg(req, 'str_def', default='def')
assert val == 'def'
val = utils.get_str_arg(req, 'empty_str')
assert val is None
with mock.patch('{}.str'.format(builtin_pkg), mock.Mock(side_effect=Exception)):
val = utils.get_str_arg(req, 'str', default='def')
assert val == 'def'
val = utils.get_int_arg(req, 'int')
assert isinstance(val, int) and val == 1
val = utils.get_int_arg(req, 'int_def', default=2)
assert val == 2
val = utils.get_int_arg(req, 'empty_int')
assert val is None
with mock.patch('{}.int'.format(builtin_pkg), mock.Mock(side_effect=Exception)):
val = utils.get_int_arg(req, 'int', default=2)
assert val == 2
val = utils.get_bool_arg(req, 'bool')
assert isinstance(val, bool) and val
val = utils.get_float_arg(req, 'float')
assert isinstance(val, float) and val == 1.1
val = utils.get_float_arg(req, 'int_def', default=2.0)
def test_make_list():
assert utils.make_list(None) == []
assert utils.make_list([1]) == [1]
assert utils.make_list(1) == [1]
def test_make_list():
assert utils.make_list(None) == []
assert utils.make_list([1]) == [1]
assert utils.make_list(1) == [1]
def test_classify_type():
assert utils.classify_type('string') == 'S'
assert utils.classify_type('boolean') == 'B'
assert utils.classify_type('float64') == 'F'
assert utils.classify_type('integer64') == 'I'
assert utils.classify_type('timestamp') == 'D'
assert utils.classify_type('timedelta') == 'TD'
assert utils.classify_type('foo') == 'S'
def test_classify_type():
assert utils.classify_type('string') == 'S'
assert utils.classify_type('boolean') == 'B'
assert utils.classify_type('float64') == 'F'
assert utils.classify_type('integer64') == 'I'
assert utils.classify_type('timestamp') == 'D'
assert utils.classify_type('timedelta') == 'TD'
assert utils.classify_type('foo') == 'S'
def test_classify_type():
assert utils.classify_type('string') == 'S'
assert utils.classify_type('boolean') == 'B'
assert utils.classify_type('float64') == 'F'
assert utils.classify_type('integer64') == 'I'
assert utils.classify_type('timestamp') == 'D'
assert utils.classify_type('timedelta') == 'TD'
assert utils.classify_type('foo') == 'S'
def test_classify_type():
assert utils.classify_type('string') == 'S'
assert utils.classify_type('boolean') == 'B'
assert utils.classify_type('float64') == 'F'
assert utils.classify_type('integer64') == 'I'
assert utils.classify_type('timestamp') == 'D'
assert utils.classify_type('timedelta') == 'TD'
assert utils.classify_type('foo') == 'S'
def test_classify_type():
assert utils.classify_type('string') == 'S'
assert utils.classify_type('boolean') == 'B'
assert utils.classify_type('float64') == 'F'
assert utils.classify_type('integer64') == 'I'
assert utils.classify_type('timestamp') == 'D'
assert utils.classify_type('timedelta') == 'TD'
assert utils.classify_type('foo') == 'S'
def test_classify_type():
assert utils.classify_type('string') == 'S'
assert utils.classify_type('boolean') == 'B'
assert utils.classify_type('float64') == 'F'
assert utils.classify_type('integer64') == 'I'
assert utils.classify_type('timestamp') == 'D'
assert utils.classify_type('timedelta') == 'TD'
assert utils.classify_type('foo') == 'S'