##// 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 22 import pytest
23 23
24 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 29 class TestHelperFunctions(object):
@@ -76,6 +77,32 b' class TestHelperFunctions(object):'
76 77 _list_setting(settings, key, None)
77 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 107 class TestSanitizeVcsSettings(object):
81 108 _bool_settings = [
General Comments 0
You need to be logged in to leave comments. Login now