This is an automated email from the ASF dual-hosted git repository. dill0wn pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/allura.git
commit 955d0fbbef1ed6c3f2b4d3d77ce8d73d74ee353e Author: Guillermo Cruz <[email protected]> AuthorDate: Mon Jan 23 00:51:25 2023 +0000 [#8494] test fixes --- Allura/allura/tasks/mail_tasks.py | 2 +- Allura/allura/tests/test_helpers.py | 4 ++-- Allura/allura/tests/test_tasks.py | 4 ++-- .../allura/tests/unit/test_ldap_auth_provider.py | 8 +++---- .../forgegit/tests/functional/test_controllers.py | 28 ++++++++++++++-------- ForgeSVN/forgesvn/tests/model/test_repository.py | 2 +- ForgeSVN/forgesvn/tests/test_tasks.py | 2 +- 7 files changed, 29 insertions(+), 21 deletions(-) diff --git a/Allura/allura/tasks/mail_tasks.py b/Allura/allura/tasks/mail_tasks.py index 16cf82dae..e2b2a0a15 100644 --- a/Allura/allura/tasks/mail_tasks.py +++ b/Allura/allura/tasks/mail_tasks.py @@ -117,7 +117,7 @@ def create_multipart_msg(text, metalink=None): def replace_html(matchobj): text_within_div = matchobj.group(1) text_within_div = text_within_div.replace('</p>', '\n') - text_within_div = markupsafe._striptags_re.sub('', text_within_div) + text_within_div = markupsafe._strip_tags_re.sub('', text_within_div) return text_within_div plain_text = text diff --git a/Allura/allura/tests/test_helpers.py b/Allura/allura/tests/test_helpers.py index c686a9e32..931c6908c 100644 --- a/Allura/allura/tests/test_helpers.py +++ b/Allura/allura/tests/test_helpers.py @@ -266,11 +266,11 @@ def test_render_any_markup_plain(): def test_render_any_markup_formatting(): assert (str(h.render_any_markup('README.md', '### foo\n' - ' <script>alert(1)</script> bar')) == + ' <script>alert(1)</script>bar')) == '<div class="markdown_content"><h3 id="foo">foo</h3>\n' '<div class="codehilite"><pre><span></span><code><span class="nt">' '<script></span>alert(1)<span class="nt">' - '</script></span> bar\n</code></pre></div>\n</div>') + '</script></span>bar\n</code></pre></div>\n</div>') def test_render_any_markdown_encoding(): diff --git a/Allura/allura/tests/test_tasks.py b/Allura/allura/tests/test_tasks.py index 275c36455..a4cfdbe86 100644 --- a/Allura/allura/tests/test_tasks.py +++ b/Allura/allura/tests/test_tasks.py @@ -579,8 +579,8 @@ class TestNotificationTasks(unittest.TestCase): with mock.patch.object(M.Mailbox, 'deliver') as deliver: with mock.patch.object(M.Mailbox, 'fire_ready') as fire_ready: notification_tasks.notify('42', ['52'], 'none') - assert deliver.called_with('42', ['52'], 'none') - assert fire_ready.called_with() + deliver.assert_called_with('42', ['52'], 'none') + fire_ready.assert_called_with() @event_handler('my_event') diff --git a/Allura/allura/tests/unit/test_ldap_auth_provider.py b/Allura/allura/tests/unit/test_ldap_auth_provider.py index 1b0967dfc..8a43f1763 100644 --- a/Allura/allura/tests/unit/test_ldap_auth_provider.py +++ b/Allura/allura/tests/unit/test_ldap_auth_provider.py @@ -61,7 +61,7 @@ class TestLdapAuthenticationProvider: self.provider.set_password(user, 'old-pass', 'new-pass') ldap.initialize.assert_called_once_with('ldaps://localhost/') connection = ldap.initialize.return_value - connection.bind_s.called_once_with(dn, b'old-pass') + connection.simple_bind_s.assert_called_once_with(dn, b'old-pass') connection.modify_s.assert_called_once_with( dn, [(ldap.MOD_REPLACE, 'userPassword', b'new-pass-hash')]) assert connection.unbind_s.call_count == 1 @@ -81,7 +81,7 @@ class TestLdapAuthenticationProvider: dn = 'uid=%s,ou=people,dc=localdomain' % params['username'] ldap.initialize.assert_called_once_with('ldaps://localhost/') connection = ldap.initialize.return_value - connection.bind_s.called_once_with(dn, 'test-password') + connection.simple_bind_s.assert_called_once_with(dn, b'test-password') assert connection.unbind_s.call_count == 1 @patch('allura.lib.plugin.ldap') @@ -124,9 +124,9 @@ class TestLdapAuthenticationProvider: dn = 'uid=%s,ou=people,dc=localdomain' % user_doc['username'] ldap.initialize.assert_called_once_with('ldaps://localhost/') connection = ldap.initialize.return_value - connection.bind_s.called_once_with( + connection.simple_bind_s.assert_called_once_with( 'cn=admin,dc=localdomain', - 'admin-password') + 'secret') connection.add_s.assert_called_once_with(dn, modlist.addModlist.return_value) assert connection.unbind_s.call_count == 1 diff --git a/ForgeGit/forgegit/tests/functional/test_controllers.py b/ForgeGit/forgegit/tests/functional/test_controllers.py index d42d91239..22c8d7f85 100644 --- a/ForgeGit/forgegit/tests/functional/test_controllers.py +++ b/ForgeGit/forgegit/tests/functional/test_controllers.py @@ -334,12 +334,20 @@ class TestRootController(_TestCase): ci = self._get_ci(repo='/p/test/weird-chars/') resp = self.app.get(h.urlquote(ci + 'tree/привіт.txt') + '?diff=407950e8fba4dbc108ffbce0128ed1085c52cfd7') diffhtml = str(resp.html.select_one('.diffbrowser')) + print("HTML", diffhtml) + print("=============================") + print(textwrap.dedent('''\ + <span class="gd">--- a/привіт.txt</span> + <span class="gi">+++ b/привіт.txt</span> + <span class="gu">@@ -1 +1,2 @@</span> + <span class="w"> </span>Привіт! + <span class="gi">+Which means Hello!</span>''')) assert (textwrap.dedent('''\ - <span class="gd">--- a/привіт.txt</span><span class="w"></span> - <span class="gi">+++ b/привіт.txt</span><span class="w"></span> - <span class="gu">@@ -1 +1,2 @@</span><span class="w"></span> - <span class="w"> </span>Привіт!<span class="w"></span> - <span class="gi">+Which means Hello!</span><span class="w"></span>''') in + <span class="gd">--- a/привіт.txt</span> + <span class="gi">+++ b/привіт.txt</span> + <span class="gu">@@ -1 +1,2 @@</span> + <span class="w"> </span>Привіт! + <span class="gi">+Which means Hello!</span>''') in diffhtml) resp = self.app.get(h.urlquote(ci + 'tree/привіт.txt') + '?diff=407950e8fba4dbc108ffbce0128ed1085c52cfd7&diformat=sidebyside') @@ -903,11 +911,11 @@ class TestFork(_TestCase): </li> </ul> <p>Diff:</p> -<div class="codehilite"><pre><span></span><code><span class="gd">--- old</span><span class="w"></span> -<span class="gi">+++ new</span><span class="w"></span> -<span class="gu">@@ -1 +1 @@</span><span class="w"></span> -<span class="gd">-description</span><span class="w"></span> -<span class="gi">+changed description</span><span class="w"></span> +<div class="codehilite"><pre><span></span><code><span class="gd">--- old</span> +<span class="gi">+++ new</span> +<span class="gu">@@ -1 +1 @@</span> +<span class="gd">-description</span> +<span class="gi">+changed description</span> </code></pre></div> </div> """.strip() diff --git a/ForgeSVN/forgesvn/tests/model/test_repository.py b/ForgeSVN/forgesvn/tests/model/test_repository.py index 4716bff9f..d0fd0712a 100644 --- a/ForgeSVN/forgesvn/tests/model/test_repository.py +++ b/ForgeSVN/forgesvn/tests/model/test_repository.py @@ -753,7 +753,7 @@ class TestRepo(_TestWithRepo): self.repo.init_as_clone('srcpath', 'srcname', 'srcurl') assert self.repo.upstream_repo.name == 'srcname' assert self.repo.upstream_repo.url == 'srcurl' - assert self.repo._impl.clone_from.called_with('srcpath') + self.repo._impl.clone_from.assert_called_with('srcpath') post_event.assert_called_once_with('repo_cloned', 'srcurl', 'srcpath') def test_latest(self): diff --git a/ForgeSVN/forgesvn/tests/test_tasks.py b/ForgeSVN/forgesvn/tests/test_tasks.py index b4d939eaa..f84d9dafe 100644 --- a/ForgeSVN/forgesvn/tests/test_tasks.py +++ b/ForgeSVN/forgesvn/tests/test_tasks.py @@ -55,7 +55,7 @@ class TestRepoTasks(unittest.TestCase): with mock.patch.object(c.app.repo, 'init') as f: repo_tasks.init() M.main_orm_session.flush() - assert f.called_with() + f.assert_called_with() assert ns == M.Notification.query.find().count() def test_clone(self):
