"Fossies" - the Fresh Open Source Software Archive

Member "murano-8.0.0/murano/tests/unit/engine/system/test_instance_reporter.py" (16 Oct 2019, 1922 Bytes) of package /linux/misc/openstack/murano-8.0.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #    Copyright (c) 2016 AT&T
    2 #
    3 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
    4 #    not use this file except in compliance with the License. You may obtain
    5 #    a copy of the License at
    6 #
    7 #         http://www.apache.org/licenses/LICENSE-2.0
    8 #
    9 #    Unless required by applicable law or agreed to in writing, software
   10 #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
   11 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   12 #    License for the specific language governing permissions and limitations
   13 #    under the License.
   14 
   15 import mock
   16 
   17 from murano.db import models
   18 from murano.engine.system import instance_reporter
   19 from murano.tests.unit import base
   20 
   21 LATEST_VERSION = 1
   22 
   23 
   24 class TestInstanceReporter(base.MuranoTestCase):
   25     def setUp(self):
   26         super(TestInstanceReporter, self).setUp()
   27 
   28         self.environment = models.Environment(
   29             name='test_environment', tenant_id='test_tenant_id',
   30             version=LATEST_VERSION
   31         )
   32 
   33         self.addCleanup(mock.patch.stopall)
   34 
   35     @mock.patch("murano.db.models")
   36     def test_track_untrack_application(self, mock_models):
   37         instance = mock_models.Instance()
   38         self.i_r = instance_reporter.InstanceReportNotifier(self.environment)
   39         self.assertEqual(self.environment.id, self.i_r._environment_id)
   40         self.assertIsNone(self.i_r.track_application(instance))
   41         self.assertIsNone(self.i_r.untrack_application(instance))
   42 
   43     @mock.patch("murano.db.models")
   44     def test_track_untrack_cloud_instance(self, mock_models):
   45         instance = mock_models.Instance()
   46         self.i_r = instance_reporter.InstanceReportNotifier(self.environment)
   47         self.assertEqual(self.environment.id, self.i_r._environment_id)
   48         self.assertIsNone(self.i_r.track_cloud_instance(instance))
   49         self.assertIsNone(self.i_r.untrack_cloud_instance(instance))