You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/07/16 22:22:07 UTC
[2/4] 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/dce4fe8c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/dce4fe8c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/dce4fe8c
Branch: refs/heads/master
Commit: dce4fe8c3c05109f9d9e8de7e2495ebf13b673ac
Parents: c3b47b7
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Tue Jul 2 21:36:57 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Tue Jul 16 20:15:14 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/dce4fe8c/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.')