##// END OF EJS Templates
tests: Adapt sv_support tests to recent changes....
Martin Bornhold -
r858:fe0dec67 default
parent child Browse files
Show More
@@ -19,6 +19,7 b''
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21
21
22 import codecs
22 import mock
23 import mock
23 import re
24 import re
24 import shutil
25 import shutil
@@ -30,6 +31,7 b' from rhodecode.svn_support import config'
30
31
31
32
32 class TestModDavSvnConfig(object):
33 class TestModDavSvnConfig(object):
34
33 @classmethod
35 @classmethod
34 def setup_class(cls):
36 def setup_class(cls):
35 # Make mako renderer available in tests.
37 # Make mako renderer available in tests.
@@ -39,8 +41,9 b' class TestModDavSvnConfig(object):'
39 # Temporary directory holding the generated config files.
41 # Temporary directory holding the generated config files.
40 cls.tempdir = tempfile.mkdtemp(suffix='pytest-mod-dav-svn')
42 cls.tempdir = tempfile.mkdtemp(suffix='pytest-mod-dav-svn')
41
43
42 cls.location_root = '/location/root'
44 cls.location_root = u'/location/root/ç¡Àâ'
43 cls.parent_path_root = '/parent/path/root'
45 cls.parent_path_root = u'/parent/path/ç¡Àâ'
46 cls._dummy_realm = u'Dummy Realm (Àâüç¡)'
44
47
45 @classmethod
48 @classmethod
46 def teardown_class(cls):
49 def teardown_class(cls):
@@ -61,7 +64,7 b' class TestModDavSvnConfig(object):'
61 def get_repo_groups(cls, count=1):
64 def get_repo_groups(cls, count=1):
62 repo_groups = []
65 repo_groups = []
63 for num in range(0, count):
66 for num in range(0, count):
64 full_path = '/path/to/RepoGroup{}'.format(num)
67 full_path = u'/path/to/RepâGrâúp-°¡ {}'.format(num)
65 repo_group_mock = mock.MagicMock()
68 repo_group_mock = mock.MagicMock()
66 repo_group_mock.full_path = full_path
69 repo_group_mock.full_path = full_path
67 repo_group_mock.full_path_splitted = full_path.split('/')
70 repo_group_mock.full_path_splitted = full_path.split('/')
@@ -69,11 +72,12 b' class TestModDavSvnConfig(object):'
69 return repo_groups
72 return repo_groups
70
73
71 def assert_root_location_directive(self, config):
74 def assert_root_location_directive(self, config):
72 pattern = '<Location {location}>'.format(location=self.location_root)
75 pattern = u'<Location "{location}">'.format(
76 location=self.location_root)
73 assert len(re.findall(pattern, config)) == 1
77 assert len(re.findall(pattern, config)) == 1
74
78
75 def assert_group_location_directive(self, config, group_path):
79 def assert_group_location_directive(self, config, group_path):
76 pattern = '<Location {location}{group_path}>'.format(
80 pattern = u'<Location "{location}{group_path}">'.format(
77 location=self.location_root, group_path=group_path)
81 location=self.location_root, group_path=group_path)
78 assert len(re.findall(pattern, config)) == 1
82 assert len(re.findall(pattern, config)) == 1
79
83
@@ -81,7 +85,7 b' class TestModDavSvnConfig(object):'
81 @mock.patch('rhodecode.svn_support.utils.RepoGroup')
85 @mock.patch('rhodecode.svn_support.utils.RepoGroup')
82 def test_generate_mod_dav_svn_config(self, RepoGroupMock, GetRealmMock):
86 def test_generate_mod_dav_svn_config(self, RepoGroupMock, GetRealmMock):
83 # Setup mock objects.
87 # Setup mock objects.
84 GetRealmMock.return_value = 'DummyRealm'
88 GetRealmMock.return_value = self._dummy_realm
85 num_groups = 3
89 num_groups = 3
86 RepoGroupMock.get_all_repo_groups.return_value = self.get_repo_groups(
90 RepoGroupMock.get_all_repo_groups.return_value = self.get_repo_groups(
87 count=num_groups)
91 count=num_groups)
@@ -92,8 +96,9 b' class TestModDavSvnConfig(object):'
92 settings=settings, parent_path_root=self.parent_path_root)
96 settings=settings, parent_path_root=self.parent_path_root)
93
97
94 # Read generated file.
98 # Read generated file.
95 with open(settings[config_keys.config_file_path], 'r') as file_:
99 path = settings[config_keys.config_file_path]
96 content = file_.read()
100 with codecs.open(path, 'r', encoding='utf-8') as f:
101 content = f.read()
97
102
98 # Assert that one location directive exists for each repository group.
103 # Assert that one location directive exists for each repository group.
99 for group in self.get_repo_groups(count=num_groups):
104 for group in self.get_repo_groups(count=num_groups):
@@ -106,7 +111,7 b' class TestModDavSvnConfig(object):'
106 @mock.patch('rhodecode.svn_support.utils.RepoGroup')
111 @mock.patch('rhodecode.svn_support.utils.RepoGroup')
107 def test_list_parent_path_on(self, RepoGroupMock, GetRealmMock):
112 def test_list_parent_path_on(self, RepoGroupMock, GetRealmMock):
108 # Setup mock objects.
113 # Setup mock objects.
109 GetRealmMock.return_value = 'DummyRealm'
114 GetRealmMock.return_value = self._dummy_realm
110 RepoGroupMock.get_all_repo_groups.return_value = self.get_repo_groups()
115 RepoGroupMock.get_all_repo_groups.return_value = self.get_repo_groups()
111
116
112 # Execute the method under test.
117 # Execute the method under test.
@@ -116,8 +121,9 b' class TestModDavSvnConfig(object):'
116 settings=settings, parent_path_root=self.parent_path_root)
121 settings=settings, parent_path_root=self.parent_path_root)
117
122
118 # Read generated file.
123 # Read generated file.
119 with open(settings[config_keys.config_file_path], 'r') as file_:
124 path = settings[config_keys.config_file_path]
120 content = file_.read()
125 with codecs.open(path, 'r', encoding='utf-8') as f:
126 content = f.read()
121
127
122 # Make assertions.
128 # Make assertions.
123 assert not re.search('SVNListParentPath\s+Off', content)
129 assert not re.search('SVNListParentPath\s+Off', content)
@@ -127,7 +133,7 b' class TestModDavSvnConfig(object):'
127 @mock.patch('rhodecode.svn_support.utils.RepoGroup')
133 @mock.patch('rhodecode.svn_support.utils.RepoGroup')
128 def test_list_parent_path_off(self, RepoGroupMock, GetRealmMock):
134 def test_list_parent_path_off(self, RepoGroupMock, GetRealmMock):
129 # Setup mock objects.
135 # Setup mock objects.
130 GetRealmMock.return_value = 'DummyRealm'
136 GetRealmMock.return_value = self._dummy_realm
131 RepoGroupMock.get_all_repo_groups.return_value = self.get_repo_groups()
137 RepoGroupMock.get_all_repo_groups.return_value = self.get_repo_groups()
132
138
133 # Execute the method under test.
139 # Execute the method under test.
General Comments 0
You need to be logged in to leave comments. Login now