allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kentontay...@apache.org
Subject [allura] 14/18: [#8320] upgrade mock
Date Mon, 05 Aug 2019 18:27:42 GMT
This is an automated email from the ASF dual-hosted git repository.

kentontaylor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit ca941a32ae05e1a25ff3cdd00900565eaa8ad926
Author: Dave Brondsema <dave@brondsema.net>
AuthorDate: Wed Jul 31 14:36:22 2019 -0400

    [#8320] upgrade mock
    
    * markdown_wiki changes are so that test_macro_embed can run successfully when the whole
file is run including
      test_filtering whose @with_setup(setup_functional_test) was making it fail
    * since mock 2.0 doesn't work to autospec a Ming object like M.Repository or M.MergeRequest
---
 Allura/allura/lib/app_globals.py           | 4 ++--
 Allura/allura/tests/model/test_repo.py     | 2 +-
 Allura/allura/tests/test_plugin.py         | 5 +++--
 Allura/allura/tests/test_tasks.py          | 4 ++--
 ForgeBlog/forgeblog/tests/test_commands.py | 3 +--
 requirements.in                            | 2 +-
 requirements.txt                           | 4 ++--
 7 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index 2a2581f..eb233b9 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -436,9 +436,9 @@ class Globals(object):
 
     @property
     def markdown_wiki(self):
-        if c.project.is_nbhd_project:
+        if c.project and c.project.is_nbhd_project:
             return self.forge_markdown(wiki=True, macro_context='neighborhood-wiki')
-        elif c.project.is_user_project:
+        elif c.project and c.project.is_user_project:
             return self.forge_markdown(wiki=True, macro_context='userproject-wiki')
         else:
             return self.forge_markdown(wiki=True)
diff --git a/Allura/allura/tests/model/test_repo.py b/Allura/allura/tests/model/test_repo.py
index 95263dc..7a4410a 100644
--- a/Allura/allura/tests/model/test_repo.py
+++ b/Allura/allura/tests/model/test_repo.py
@@ -103,7 +103,7 @@ class TestLastCommit(unittest.TestCase):
             name='repo',
             _commits=OrderedDict(),
             _last_commit=None,
-            spec=M.Repository)
+        )
         self.repo.paged_diffs.return_value = {
             'added': [],
             'removed': [],
diff --git a/Allura/allura/tests/test_plugin.py b/Allura/allura/tests/test_plugin.py
index b153977..6c582b1 100644
--- a/Allura/allura/tests/test_plugin.py
+++ b/Allura/allura/tests/test_plugin.py
@@ -551,14 +551,15 @@ class TestLocalAuthenticationProvider(object):
         user = Mock()
         user.__ming__ = Mock()
         self.provider.validate_password = lambda u, p: False
+        self.provider._encode_password = Mock()
         assert_raises(
             exc.HTTPUnauthorized,
             self.provider.set_password, user, 'old', 'new')
-        assert_equal(user._encode_password.call_count, 0)
+        assert_equal(self.provider._encode_password.call_count, 0)
 
         self.provider.validate_password = lambda u, p: True
         self.provider.set_password(user, 'old', 'new')
-        user._encode_password.assert_callued_once_with('new')
+        self.provider._encode_password.assert_called_once_with('new')
 
     @patch('allura.lib.plugin.datetime', autospec=True)
     def test_set_password_sets_last_updated(self, dt_mock):
diff --git a/Allura/allura/tests/test_tasks.py b/Allura/allura/tests/test_tasks.py
index 274a291..37a89f1 100644
--- a/Allura/allura/tests/test_tasks.py
+++ b/Allura/allura/tests/test_tasks.py
@@ -65,7 +65,7 @@ class TestRepoTasks(unittest.TestCase):
         # ignore args[3] which is a traceback string
 
     @mock.patch('allura.tasks.repo_tasks.session', autospec=True)
-    @mock.patch.object(M, 'MergeRequest', autospec=True)
+    @mock.patch.object(M, 'MergeRequest')
     def test_merge(self, MR, session):
         mr = mock.Mock(_id='_id',
                        activity_name='merge req', activity_url='/fake/url', activity_extras={},
node_id=None)
@@ -76,7 +76,7 @@ class TestRepoTasks(unittest.TestCase):
         session.assert_called_once_with(mr)
         session.return_value.flush.assert_called_once_with(mr)
 
-    @mock.patch.object(M, 'MergeRequest', autospec=True)
+    @mock.patch.object(M, 'MergeRequest')
     def test_can_merge(self, MR):
         mr = M.MergeRequest(_id='_id')
         MR.query.get.return_value = mr
diff --git a/ForgeBlog/forgeblog/tests/test_commands.py b/ForgeBlog/forgeblog/tests/test_commands.py
index 6fb32fe..03b382a 100644
--- a/ForgeBlog/forgeblog/tests/test_commands.py
+++ b/ForgeBlog/forgeblog/tests/test_commands.py
@@ -28,7 +28,7 @@ from ming.orm.ormsession import ThreadLocalORMSession
 from alluratest.controller import setup_basic_test, setup_global_objects
 from allura import model as M
 from forgeblog import model as BM
-
+from forgeblog.command import rssfeeds  # note that importing this sets html2text.BODY_WIDTH
to a new value
 
 test_config = pkg_resources.resource_filename(
     'allura', '../test.ini') + '#main'
@@ -114,7 +114,6 @@ def test_pull_rss_feeds(parsefeed):
     BM.Globals(app_config_id=tmp_app._id, external_feeds=new_external_feeds)
     ThreadLocalORMSession.flush_all()
 
-    from forgeblog.command import rssfeeds
     cmd = rssfeeds.RssFeedsCommand('pull-rss-feeds')
     cmd.run([test_config, '-a', tmp_app._id])
     cmd.command()
diff --git a/requirements.in b/requirements.in
index 4b47419..cfdf446 100644
--- a/requirements.in
+++ b/requirements.in
@@ -48,7 +48,7 @@ wrapt==1.11.2
 # testing
 datadiff==1.1.5
 ipython==1.2.1
-mock==1.0.1
+mock
 nose==1.3.4
 poster==0.8.1
 pyflakes
diff --git a/requirements.txt b/requirements.txt
index 2aca996..a25874e 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -30,7 +30,7 @@ enum34==1.1.6             # via astroid, colander, cryptography
 faulthandler==2.1
 feedparser==5.1.3
 formencode==1.2.4
-funcsigs==1.0.2           # via beaker
+funcsigs==1.0.2           # via beaker, mock
 future==0.17.1            # via timermiddleware
 futures==3.3.0            # via isort
 genshi==0.7.3             # via creoleparser
@@ -51,7 +51,7 @@ markdown==2.2.1
 markupsafe==1.0
 mccabe==0.6.1             # via pylint
 ming==0.5.6
-mock==1.0.1
+mock==3.0.5
 nose==1.3.4
 oauth2==1.9.0.post1
 oauthlib==3.0.2           # via requests-oauthlib


Mime
View raw message