##// 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 54 return {
55 55 config_keys.config_file_path: config_file_path,
56 56 config_keys.location_root: cls.location_root,
57 config_keys.parent_path_root: cls.parent_path_root,
58 57 config_keys.list_parent_path: True,
59 58 }
60 59
@@ -78,15 +77,19 b' class TestModDavSvnConfig(object):'
78 77 location=self.location_root, group_path=group_path)
79 78 assert len(re.findall(pattern, config)) == 1
80 79
80 @mock.patch('rhodecode.svn_support.utils.get_rhodecode_realm')
81 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 85 num_groups = 3
84 86 RepoGroupMock.get_all_repo_groups.return_value = self.get_repo_groups(
85 87 count=num_groups)
86 88
87 89 # Execute the method under test.
88 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 94 # Read generated file.
92 95 with open(settings[config_keys.config_file_path], 'r') as file_:
@@ -99,14 +102,18 b' class TestModDavSvnConfig(object):'
99 102 # Assert that the root location directive exists.
100 103 self.assert_root_location_directive(content)
101 104
105 @mock.patch('rhodecode.svn_support.utils.get_rhodecode_realm')
102 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 110 RepoGroupMock.get_all_repo_groups.return_value = self.get_repo_groups()
105 111
106 112 # Execute the method under test.
107 113 settings = self.get_settings()
108 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 118 # Read generated file.
112 119 with open(settings[config_keys.config_file_path], 'r') as file_:
@@ -116,14 +123,18 b' class TestModDavSvnConfig(object):'
116 123 assert not re.search('SVNListParentPath\s+Off', content)
117 124 assert re.search('SVNListParentPath\s+On', content)
118 125
126 @mock.patch('rhodecode.svn_support.utils.get_rhodecode_realm')
119 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 131 RepoGroupMock.get_all_repo_groups.return_value = self.get_repo_groups()
122 132
123 133 # Execute the method under test.
124 134 settings = self.get_settings()
125 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 139 # Read generated file.
129 140 with open(settings[config_keys.config_file_path], 'r') as file_:
@@ -132,15 +143,3 b' class TestModDavSvnConfig(object):'
132 143 # Make assertions.
133 144 assert re.search('SVNListParentPath\s+Off', content)
134 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