##// END OF EJS Templates
tests: fix integration test wrong named variable
dan -
r436:6048dd9a default
parent child Browse files
Show More
@@ -1,78 +1,78 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 # Copyright (C) 2010-2016 RhodeCode GmbH
3 # Copyright (C) 2010-2016 RhodeCode GmbH
4 #
4 #
5 # This program is free software: you can redistribute it and/or modify
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License, version 3
6 # it under the terms of the GNU Affero General Public License, version 3
7 # (only), as published by the Free Software Foundation.
7 # (only), as published by the Free Software Foundation.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU Affero General Public License
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #
16 #
17 # This program is dual-licensed. If you wish to learn more about the
17 # This program is dual-licensed. If you wish to learn more about the
18 # RhodeCode Enterprise Edition, including its added features, Support services,
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 import pytest
21 import pytest
22 import requests
22 import requests
23 from mock import Mock, patch
23 from mock import Mock, patch
24
24
25 from rhodecode import events
25 from rhodecode import events
26 from rhodecode.model.db import Session, Integration
26 from rhodecode.model.db import Session, Integration
27 from rhodecode.model.integration import IntegrationModel
27 from rhodecode.model.integration import IntegrationModel
28 from rhodecode.integrations.types.base import IntegrationTypeBase
28 from rhodecode.integrations.types.base import IntegrationTypeBase
29
29
30
30
31 class TestIntegrationType(IntegrationTypeBase):
31 class TestIntegrationType(IntegrationTypeBase):
32 """ Test integration type class """
32 """ Test integration type class """
33
33
34 key = 'test-integration'
34 key = 'test-integration'
35 display_name = 'Test integration type'
35 display_name = 'Test integration type'
36
36
37 def __init__(self, settings):
37 def __init__(self, settings):
38 super(IntegrationTypeBase, self).__init__(settings)
38 super(IntegrationTypeBase, self).__init__(settings)
39 self.sent_events = [] # for testing
39 self.sent_events = [] # for testing
40
40
41 def send_event(self, event):
41 def send_event(self, event):
42 self.sent_events.append(event)
42 self.sent_events.append(event)
43
43
44
44
45 @pytest.fixture
45 @pytest.fixture
46 def repo_integration_stub(request, repo_stub):
46 def repo_integration_stub(request, repo_stub):
47 settings = {'test_key': 'test_value'}
47 settings = {'test_key': 'test_value'}
48 integration = IntegrationModel().create(
48 integration = IntegrationModel().create(
49 TestIntegrationType, settings=settings, repo=repo_stub, enabled=True,
49 TestIntegrationType, settings=settings, repo=repo_stub, enabled=True,
50 name='test repo integration')
50 name='test repo integration')
51
51
52 @request.addfinalizer
52 @request.addfinalizer
53 def cleanup():
53 def cleanup():
54 IntegrationModel().delete(integration)
54 IntegrationModel().delete(integration)
55
55
56 return integration
56 return integration
57
57
58
58
59 @pytest.fixture
59 @pytest.fixture
60 def global_integration_stub(request):
60 def global_integration_stub(request):
61 settings = {'test_key': 'test_value'}
61 settings = {'test_key': 'test_value'}
62 integration = IntegrationModel().create(
62 integration = IntegrationModel().create(
63 TestIntegrationType, settings=settings, enabled=True,
63 TestIntegrationType, settings=settings, enabled=True,
64 name='test global integration')
64 name='test global integration')
65
65
66 @request.addfinalizer
66 @request.addfinalizer
67 def cleanup():
67 def cleanup():
68 IntegrationModel().delete(integration)
68 IntegrationModel().delete(integration)
69
69
70 return integration
70 return integration
71
71
72
72
73 def test_delete_repo_with_integration_deletes_integration(repo_integration):
73 def test_delete_repo_with_integration_deletes_integration(repo_integration_stub):
74 Session().delete(repo_integration.repo)
74 Session().delete(repo_integration_stub.repo)
75 Session().commit()
75 Session().commit()
76 Session().expire_all()
76 Session().expire_all()
77 assert Integration.get(repo_integration.integration_id) is None
77 assert Integration.get(repo_integration_stub.integration_id) is None
78
78
General Comments 0
You need to be logged in to leave comments. Login now