You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by je...@apache.org on 2015/02/18 12:40:56 UTC
allura git commit: [#4542] Use different repo in each test class for
webhooks
Repository: allura
Updated Branches:
refs/heads/ib/4542-tests [created] 475a5f8fe
[#4542] Use different repo in each test class for webhooks
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/475a5f8f
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/475a5f8f
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/475a5f8f
Branch: refs/heads/ib/4542-tests
Commit: 475a5f8fe83b36c95cec15b944e6d687ec92af38
Parents: b967bc5
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Feb 18 11:40:18 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Feb 18 11:40:18 2015 +0000
----------------------------------------------------------------------
Allura/allura/tests/test_webhooks.py | 64 +++++++++++++++++++++++--------
1 file changed, 48 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/475a5f8f/Allura/allura/tests/test_webhooks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_webhooks.py b/Allura/allura/tests/test_webhooks.py
index c0f9140..85243d8 100644
--- a/Allura/allura/tests/test_webhooks.py
+++ b/Allura/allura/tests/test_webhooks.py
@@ -34,15 +34,21 @@ from alluratest.controller import setup_basic_test, TestController
test_project_with_repo = 'adobe-1'
with_git = td.with_tool(test_project_with_repo, 'git', 'src', 'Git')
with_git2 = td.with_tool(test_project_with_repo, 'git', 'src2', 'Git2')
+with_git3 = td.with_tool(test_project_with_repo, 'git', 'src3', 'Git3')
+with_git4 = td.with_tool(test_project_with_repo, 'git', 'src4', 'Git4')
+with_git5 = td.with_tool(test_project_with_repo, 'git', 'src5', 'Git5')
+with_git6 = td.with_tool(test_project_with_repo, 'git', 'src6', 'Git6')
+with_git7 = td.with_tool(test_project_with_repo, 'git', 'src7', 'Git7')
class TestWebhookBase(object):
+ _multiprocess_shared_ = True
- def setUp(self):
+ def setUp(self, app='src'):
setup_basic_test()
self.setup_with_tools()
self.project = M.Project.query.get(shortname=test_project_with_repo)
- self.git = self.project.app_instance('src')
+ self.git = self.project.app_instance(app)
self.wh = M.Webhook(
type='repo-push',
app_config_id=self.git.config._id,
@@ -50,18 +56,22 @@ class TestWebhookBase(object):
secret='secret')
session(self.wh).flush(self.wh)
- @with_git
- def setup_with_tools(self):
- pass
-
class TestValidators(TestWebhookBase):
+ _multiprocess_shared_ = True
- @with_git2
+ def setUp(self):
+ super(TestValidators, self).setUp(app='src6')
+
+ @with_git6
+ def setup_with_tools(self):
+ pass
+
+ @with_git7
def test_webhook_validator(self):
sender = Mock(type='repo-push')
app = self.git
- invalid_app = self.project.app_instance('src2')
+ invalid_app = self.project.app_instance('src7')
v = WebhookValidator(sender=sender, app=app, not_empty=True)
with assert_raises(Invalid) as cm:
v.to_python(None)
@@ -94,6 +104,7 @@ class TestValidators(TestWebhookBase):
class TestWebhookController(TestController):
+ _multiprocess_shared_ = True
def setUp(self):
super(TestWebhookController, self).setUp()
@@ -369,12 +380,17 @@ class TestWebhookController(TestController):
class TestSendWebhookHelper(TestWebhookBase):
+ _multiprocess_shared_ = True
- def setUp(self, *args, **kw):
- super(TestSendWebhookHelper, self).setUp(*args, **kw)
+ def setUp(self):
+ super(TestSendWebhookHelper, self).setUp(app='src3')
self.payload = {'some': ['data', 23]}
self.h = SendWebhookHelper(self.wh, self.payload)
+ @with_git3
+ def setup_with_tools(self):
+ pass
+
def test_timeout(self):
assert_equal(self.h.timeout, 30)
with h.push_config(config, **{'webhook.timeout': 10}):
@@ -397,14 +413,14 @@ class TestSendWebhookHelper(TestWebhookBase):
def test_log_msg(self):
assert_equal(
self.h.log_msg('OK'),
- 'OK: repo-push http://httpbin.org/post /adobe/adobe-1/src/')
+ 'OK: repo-push http://httpbin.org/post /adobe/adobe-1/src3/')
response = Mock(
status_code=500,
text='that is why',
headers={'Content-Type': 'application/json'})
assert_equal(
self.h.log_msg('Error', response=response),
- "Error: repo-push http://httpbin.org/post /adobe/adobe-1/src/ 500 "
+ "Error: repo-push http://httpbin.org/post /adobe/adobe-1/src3/ 500 "
"that is why {'Content-Type': 'application/json'}")
@patch('allura.webhooks.SendWebhookHelper', autospec=True)
@@ -474,6 +490,14 @@ class TestSendWebhookHelper(TestWebhookBase):
class TestRepoPushWebhookSender(TestWebhookBase):
+ _multiprocess_shared_ = True
+
+ def setUp(self):
+ super(TestRepoPushWebhookSender, self).setUp(app='src4')
+
+ @with_git4
+ def setup_with_tools(self):
+ pass
@patch('allura.webhooks.send_webhook', autospec=True)
def test_send(self, send_webhook):
@@ -531,9 +555,9 @@ class TestRepoPushWebhookSender(TestWebhookBase):
'after': u'1',
'before': u'0',
'repository': {
- 'full_name': u'/adobe/adobe-1/src/',
- 'name': u'Git',
- 'url': u'http://localhost/adobe/adobe-1/src/',
+ 'full_name': u'/adobe/adobe-1/src4/',
+ 'name': u'Git4',
+ 'url': u'http://localhost/adobe/adobe-1/src4/',
},
}
assert_equal(result, expected_result)
@@ -581,10 +605,18 @@ class TestRepoPushWebhookSender(TestWebhookBase):
class TestModels(TestWebhookBase):
+ _multiprocess_shared_ = True
+
+ def setUp(self):
+ super(TestModels, self).setUp(app='src5')
+
+ @with_git5
+ def setup_with_tools(self):
+ pass
def test_webhook_url(self):
assert_equal(self.wh.url(),
- '/adobe/adobe-1/admin/src/webhooks/repo-push/{}'.format(self.wh._id))
+ '/adobe/adobe-1/admin/src5/webhooks/repo-push/{}'.format(self.wh._id))
def test_webhook_enforce_limit(self):
self.wh.last_sent = None