You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by tv...@apache.org on 2013/07/02 23:37:16 UTC
[2/2] git commit: [#4656] Add tests for new provider methods
[#4656] Add tests for new provider methods
Signed-off-by: Tim Van Steenburgh <tv...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/29e53016
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/29e53016
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/29e53016
Branch: refs/heads/tv/4656
Commit: 29e5301647466948712d02154cfbdcf528c6f57c
Parents: 4a72332
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Tue Jul 2 21:36:57 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Tue Jul 2 21:36:57 2013 +0000
----------------------------------------------------------------------
Allura/allura/tests/test_plugin.py | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/29e53016/Allura/allura/tests/test_plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_plugin.py b/Allura/allura/tests/test_plugin.py
index 6e1a07a..aa2aaeb 100644
--- a/Allura/allura/tests/test_plugin.py
+++ b/Allura/allura/tests/test_plugin.py
@@ -16,7 +16,7 @@
# under the License.
from nose.tools import assert_equals
-from mock import MagicMock, patch
+from mock import Mock, MagicMock, patch
from allura import model as M
from allura.lib.utils import TruthyCallable
@@ -25,16 +25,31 @@ from allura.lib.plugin import ProjectRegistrationProvider
class TestProjectRegistrationProvider(object):
+ def setUp(self):
+ self.provider = ProjectRegistrationProvider()
+
@patch('allura.lib.security.has_access')
def test_validate_project_15char_user(self, has_access):
has_access.return_value = TruthyCallable(lambda: True)
- provider = ProjectRegistrationProvider()
nbhd = M.Neighborhood()
- provider.validate_project(
+ self.provider.validate_project(
neighborhood=nbhd,
shortname='u/' + ('a' * 15),
project_name='15 char username',
user=MagicMock(),
user_project=True,
private_project=False,
- )
\ No newline at end of file
+ )
+
+ def test_suggest_name(self):
+ f = self.provider.suggest_name
+ assert_equals(f('A More Than Fifteen Character Name', Mock()),
+ 'amorethanfifteencharactername')
+
+ def test_validate_project_shortname(self):
+ f = self.provider.validate_project_shortname
+ p = Mock()
+ assert_equals(f('thisislegit', p), None)
+ assert_equals(f('this is invalid and too long', p),
+ 'Please use only letters, numbers, and dashes '
+ '3-15 characters long.')