allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [3/4] allura git commit: [#7813] ticket:711 Add/fix tests
Date Mon, 19 Jan 2015 15:29:42 GMT
[#7813] ticket:711 Add/fix tests


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/83a75844
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/83a75844
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/83a75844

Branch: refs/heads/master
Commit: 83a75844c3f2581c51c9045ff93edfdf35bf76eb
Parents: 0e89609
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Tue Jan 13 15:52:42 2015 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Mon Jan 19 15:20:16 2015 +0000

----------------------------------------------------------------------
 Allura/allura/tests/model/test_auth.py | 15 +++++++++++++++
 Allura/allura/tests/test_mail_util.py  | 16 ++++++++--------
 2 files changed, 23 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/83a75844/Allura/allura/tests/model/test_auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_auth.py b/Allura/allura/tests/model/test_auth.py
index 8ae0faa..75ba74c 100644
--- a/Allura/allura/tests/model/test_auth.py
+++ b/Allura/allura/tests/model/test_auth.py
@@ -72,6 +72,21 @@ def test_email_address():
 
 
 @with_setup(setUp)
+def test_email_address_lookup_helpers():
+    addr = M.EmailAddress.create('TEST@DOMAIN.NET')
+    ThreadLocalORMSession.flush_all()
+    assert_equal(addr.email, 'TEST@domain.net')
+
+    assert_equal(M.EmailAddress.get(email='TEST@DOMAIN.NET'), addr)
+    assert_equal(M.EmailAddress.get(email='TEST@domain.net'), addr)
+    assert_equal(M.EmailAddress.get(email='test@domain.net'), None)
+
+    assert_equal(M.EmailAddress.find(dict(email='TEST@DOMAIN.NET')).all(), [addr])
+    assert_equal(M.EmailAddress.find(dict(email='TEST@domain.net')).all(), [addr])
+    assert_equal(M.EmailAddress.find(dict(email='test@domain.net')).all(), [])
+
+
+@with_setup(setUp)
 def test_email_address_send_verification_link():
     addr = M.EmailAddress(email='test_admin@domain.net',
                           claimed_by_user_id=c.user._id)

http://git-wip-us.apache.org/repos/asf/allura/blob/83a75844/Allura/allura/tests/test_mail_util.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_mail_util.py b/Allura/allura/tests/test_mail_util.py
index 2263940..e8d5e12 100644
--- a/Allura/allura/tests/test_mail_util.py
+++ b/Allura/allura/tests/test_mail_util.py
@@ -190,19 +190,19 @@ class TestIdentifySender(object):
     @mock.patch('allura.model.EmailAddress')
     def test_arg(self, EA):
         EA.canonical = lambda e: e
-        EA.query.get.side_effect = [
+        EA.get.side_effect = [
             mock.Mock(claimed_by_user_id=True, claimed_by_user=lambda:'user')]
         assert_equal(identify_sender(None, 'arg', None, None), 'user')
-        EA.query.get.assert_called_once_with(email='arg', confirmed=True)
+        EA.get.assert_called_once_with(email='arg', confirmed=True)
 
     @mock.patch('allura.model.EmailAddress')
     def test_header(self, EA):
         EA.canonical = lambda e: e
-        EA.query.get.side_effect = [
+        EA.get.side_effect = [
             None, mock.Mock(claimed_by_user_id=True, claimed_by_user=lambda:'user')]
         assert_equal(
             identify_sender(None, 'arg', {'From': 'from'}, None), 'user')
-        assert_equal(EA.query.get.call_args_list,
+        assert_equal(EA.get.call_args_list,
                      [mock.call(email='arg', confirmed=True), mock.call(email='from')])
 
     @mock.patch('allura.model.User')
@@ -210,20 +210,20 @@ class TestIdentifySender(object):
     def test_no_header(self, EA, User):
         anon = User.anonymous()
         EA.canonical = lambda e: e
-        EA.query.get.side_effect = [
+        EA.get.side_effect = [
             None, mock.Mock(claimed_by_user_id=True, claimed_by_user=lambda:'user')]
         assert_equal(identify_sender(None, 'arg', {}, None), anon)
-        assert_equal(EA.query.get.call_args_list, [mock.call(email='arg', confirmed=True)])
+        assert_equal(EA.get.call_args_list, [mock.call(email='arg', confirmed=True)])
 
     @mock.patch('allura.model.User')
     @mock.patch('allura.model.EmailAddress')
     def test_no_match(self, EA, User):
         anon = User.anonymous()
         EA.canonical = lambda e: e
-        EA.query.get.side_effect = [None, None]
+        EA.get.side_effect = [None, None]
         assert_equal(
             identify_sender(None, 'arg', {'From': 'from'}, None), anon)
-        assert_equal(EA.query.get.call_args_list,
+        assert_equal(EA.get.call_args_list,
                      [mock.call(email='arg', confirmed=True), mock.call(email='from')])
 
 


Mime
View raw message