##// END OF EJS Templates
svn-support: Fix tests.
Martin Bornhold -
r832:f6b7d5a9 default
parent child Browse files
Show More
@@ -54,7 +54,6 b' class TestModDavSvnConfig(object):'
54 return {
54 return {
55 config_keys.config_file_path: config_file_path,
55 config_keys.config_file_path: config_file_path,
56 config_keys.location_root: cls.location_root,
56 config_keys.location_root: cls.location_root,
57 config_keys.parent_path_root: cls.parent_path_root,
58 config_keys.list_parent_path: True,
57 config_keys.list_parent_path: True,
59 }
58 }
60
59
@@ -78,15 +77,19 b' class TestModDavSvnConfig(object):'
78 location=self.location_root, group_path=group_path)
77 location=self.location_root, group_path=group_path)
79 assert len(re.findall(pattern, config)) == 1
78 assert len(re.findall(pattern, config)) == 1
80
79
80 @mock.patch('rhodecode.svn_support.utils.get_rhodecode_realm')
81 @mock.patch('rhodecode.svn_support.utils.RepoGroup')
81 @mock.patch('rhodecode.svn_support.utils.RepoGroup')
82 def test_generate_mod_dav_svn_config(self, RepoGroupMock):
82 def test_generate_mod_dav_svn_config(self, RepoGroupMock, GetRealmMock):
83 # Setup mock objects.
84 GetRealmMock.return_value = 'DummyRealm'
83 num_groups = 3
85 num_groups = 3
84 RepoGroupMock.get_all_repo_groups.return_value = self.get_repo_groups(
86 RepoGroupMock.get_all_repo_groups.return_value = self.get_repo_groups(
85 count=num_groups)
87 count=num_groups)
86
88
87 # Execute the method under test.
89 # Execute the method under test.
88 settings = self.get_settings()
90 settings = self.get_settings()
89 utils.generate_mod_dav_svn_config(settings)
91 utils.generate_mod_dav_svn_config(
92 settings=settings, parent_path_root=self.parent_path_root)
90
93
91 # Read generated file.
94 # Read generated file.
92 with open(settings[config_keys.config_file_path], 'r') as file_:
95 with open(settings[config_keys.config_file_path], 'r') as file_:
@@ -99,14 +102,18 b' class TestModDavSvnConfig(object):'
99 # Assert that the root location directive exists.
102 # Assert that the root location directive exists.
100 self.assert_root_location_directive(content)
103 self.assert_root_location_directive(content)
101
104
105 @mock.patch('rhodecode.svn_support.utils.get_rhodecode_realm')
102 @mock.patch('rhodecode.svn_support.utils.RepoGroup')
106 @mock.patch('rhodecode.svn_support.utils.RepoGroup')
103 def test_list_parent_path_on(self, RepoGroupMock):
107 def test_list_parent_path_on(self, RepoGroupMock, GetRealmMock):
108 # Setup mock objects.
109 GetRealmMock.return_value = 'DummyRealm'
104 RepoGroupMock.get_all_repo_groups.return_value = self.get_repo_groups()
110 RepoGroupMock.get_all_repo_groups.return_value = self.get_repo_groups()
105
111
106 # Execute the method under test.
112 # Execute the method under test.
107 settings = self.get_settings()
113 settings = self.get_settings()
108 settings[config_keys.list_parent_path] = True
114 settings[config_keys.list_parent_path] = True
109 utils.generate_mod_dav_svn_config(settings)
115 utils.generate_mod_dav_svn_config(
116 settings=settings, parent_path_root=self.parent_path_root)
110
117
111 # Read generated file.
118 # Read generated file.
112 with open(settings[config_keys.config_file_path], 'r') as file_:
119 with open(settings[config_keys.config_file_path], 'r') as file_:
@@ -116,14 +123,18 b' class TestModDavSvnConfig(object):'
116 assert not re.search('SVNListParentPath\s+Off', content)
123 assert not re.search('SVNListParentPath\s+Off', content)
117 assert re.search('SVNListParentPath\s+On', content)
124 assert re.search('SVNListParentPath\s+On', content)
118
125
126 @mock.patch('rhodecode.svn_support.utils.get_rhodecode_realm')
119 @mock.patch('rhodecode.svn_support.utils.RepoGroup')
127 @mock.patch('rhodecode.svn_support.utils.RepoGroup')
120 def test_list_parent_path_off(self, RepoGroupMock):
128 def test_list_parent_path_off(self, RepoGroupMock, GetRealmMock):
129 # Setup mock objects.
130 GetRealmMock.return_value = 'DummyRealm'
121 RepoGroupMock.get_all_repo_groups.return_value = self.get_repo_groups()
131 RepoGroupMock.get_all_repo_groups.return_value = self.get_repo_groups()
122
132
123 # Execute the method under test.
133 # Execute the method under test.
124 settings = self.get_settings()
134 settings = self.get_settings()
125 settings[config_keys.list_parent_path] = False
135 settings[config_keys.list_parent_path] = False
126 utils.generate_mod_dav_svn_config(settings)
136 utils.generate_mod_dav_svn_config(
137 settings=settings, parent_path_root=self.parent_path_root)
127
138
128 # Read generated file.
139 # Read generated file.
129 with open(settings[config_keys.config_file_path], 'r') as file_:
140 with open(settings[config_keys.config_file_path], 'r') as file_:
@@ -132,15 +143,3 b' class TestModDavSvnConfig(object):'
132 # Make assertions.
143 # Make assertions.
133 assert re.search('SVNListParentPath\s+Off', content)
144 assert re.search('SVNListParentPath\s+Off', content)
134 assert not re.search('SVNListParentPath\s+On', content)
145 assert not re.search('SVNListParentPath\s+On', content)
135
136 @mock.patch('rhodecode.svn_support.utils.log')
137 def test_write_does_not_raise_on_error(self, LogMock):
138 """
139 Writing the configuration to file should never raise exceptions.
140 If e.g. path points to a place without write permissions.
141 """
142 utils._write_mod_dav_svn_config(
143 'content', '/dev/null/not/existing/path')
144
145 # Assert that we log the exception.
146 assert LogMock.exception.called
General Comments 0
You need to be logged in to leave comments. Login now