##// END OF EJS Templates
tests: Test sanitize helper function for integer settings.
Martin Bornhold -
r624:e0a65beb default
parent child Browse files
Show More
@@ -22,7 +22,8 b''
22 import pytest
22 import pytest
23
23
24 from rhodecode.config.middleware import (
24 from rhodecode.config.middleware import (
25 _sanitize_vcs_settings, _bool_setting, _string_setting, _list_setting)
25 _sanitize_vcs_settings, _bool_setting, _string_setting, _list_setting,
26 _int_setting)
26
27
27
28
28 class TestHelperFunctions(object):
29 class TestHelperFunctions(object):
@@ -76,6 +77,32 b' class TestHelperFunctions(object):'
76 _list_setting(settings, key, None)
77 _list_setting(settings, key, None)
77 assert settings[key] == expected
78 assert settings[key] == expected
78
79
80 @pytest.mark.parametrize('raw, expected', [
81 ('0', 0),
82 ('-0', 0),
83 ('12345', 12345),
84 ('-12345', -12345),
85 (u'-12345', -12345),
86 ])
87 def test_int_setting_helper(self, raw, expected):
88 key = 'dummy-key'
89 settings = {key: raw}
90 _int_setting(settings, key, None)
91 assert settings[key] == expected
92
93 @pytest.mark.parametrize('raw', [
94 ('0xff'),
95 (''),
96 ('invalid-int'),
97 ('invalid-⁄~†'),
98 (u'invalid-⁄~†'),
99 ])
100 def test_int_setting_helper_invalid_input(self, raw):
101 key = 'dummy-key'
102 settings = {key: raw}
103 with pytest.raises(Exception):
104 _int_setting(settings, key, None)
105
79
106
80 class TestSanitizeVcsSettings(object):
107 class TestSanitizeVcsSettings(object):
81 _bool_settings = [
108 _bool_settings = [
General Comments 0
You need to be logged in to leave comments. Login now