~ubuntu-branches/ubuntu/wily/heat/wily

« back to all changes in this revision

Viewing changes to heat/tests/engine/test_sync_point.py

  • Committer: Package Import Robot
  • Author(s): Corey Bryant
  • Date: 2015-08-19 08:11:50 UTC
  • mfrom: (1.1.27)
  • Revision ID: package-import@ubuntu.com-20150819081150-m969fd35xn8bdmfu
Tags: 1:5.0.0~b2-0ubuntu1
* New upstream milestone for OpenStack Liberty.
* d/control: Align (build-)depends with upstream.
* d/p/fix-requirements.patch: Dropped. No longer needed.
* d/p/fixup-assert-regex.patch: Rebased.
* d/rules: Remove .eggs directory in override_dh_auto_clean.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# Licensed under the Apache License, Version 2.0 (the "License");
 
3
# you may not use this file except in compliance with the License.
 
4
# You may obtain a copy of the License at
 
5
#
 
6
#    http://www.apache.org/licenses/LICENSE-2.0
 
7
#
 
8
# Unless required by applicable law or agreed to in writing, software
 
9
# distributed under the License is distributed on an "AS IS" BASIS,
 
10
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 
11
# implied.
 
12
# See the License for the specific language governing permissions and
 
13
# limitations under the License.
 
14
 
 
15
import mock
 
16
 
 
17
from heat.engine import sync_point
 
18
from heat.tests import common
 
19
from heat.tests.engine import tools
 
20
from heat.tests import utils
 
21
 
 
22
 
 
23
class SyncPointTestCase(common.HeatTestCase):
 
24
    def test_sync_waiting(self):
 
25
        ctx = utils.dummy_context()
 
26
        stack = tools.get_stack('test_stack', utils.dummy_context(),
 
27
                                template=tools.string_template_five,
 
28
                                convergence=True)
 
29
        stack.converge_stack(stack.t, action=stack.CREATE)
 
30
        resource = stack['C']
 
31
        graph = stack.convergence_dependencies.graph()
 
32
 
 
33
        sender = (4, True)
 
34
        mock_callback = mock.Mock()
 
35
        sync_point.sync(ctx, resource.id, stack.current_traversal, True,
 
36
                        mock_callback, set(graph[(resource.id, True)]),
 
37
                        {sender: None})
 
38
        updated_sync_point = sync_point.get(ctx, resource.id,
 
39
                                            stack.current_traversal, True)
 
40
        input_data = sync_point.deserialize_input_data(
 
41
            updated_sync_point.input_data)
 
42
        self.assertEqual({sender: None}, input_data)
 
43
        self.assertFalse(mock_callback.called)
 
44
 
 
45
    def test_sync_non_waiting(self):
 
46
        ctx = utils.dummy_context()
 
47
        stack = tools.get_stack('test_stack', utils.dummy_context(),
 
48
                                template=tools.string_template_five,
 
49
                                convergence=True)
 
50
        stack.converge_stack(stack.t, action=stack.CREATE)
 
51
        resource = stack['A']
 
52
        graph = stack.convergence_dependencies.graph()
 
53
 
 
54
        sender = (3, True)
 
55
        mock_callback = mock.Mock()
 
56
        sync_point.sync(ctx, resource.id, stack.current_traversal, True,
 
57
                        mock_callback, set(graph[(resource.id, True)]),
 
58
                        {sender: None})
 
59
        updated_sync_point = sync_point.get(ctx, resource.id,
 
60
                                            stack.current_traversal, True)
 
61
        input_data = sync_point.deserialize_input_data(
 
62
            updated_sync_point.input_data)
 
63
        self.assertEqual({sender: None}, input_data)
 
64
        self.assertTrue(mock_callback.called)
 
65
 
 
66
    def test_serialize_input_data(self):
 
67
        res = sync_point.serialize_input_data({(3, 8): None})
 
68
        self.assertEqual({'input_data': [[[3, 8], None]]}, res)