~ubuntu-branches/ubuntu/vivid/openstack-trove/vivid

« back to all changes in this revision

Viewing changes to trove/tests/unittests/guestagent/test_couchdb_manager.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Chuck Short, James Page
  • Date: 2015-04-15 14:03:27 UTC
  • mfrom: (1.1.16)
  • Revision ID: package-import@ubuntu.com-20150415140327-wwtye76elw9uu6ku
Tags: 2015.1~rc1-0ubuntu1
[ Chuck Short ]
* New upstream release.
  - d/control: Align with upstream dependencies.
  - d/p/fix-requirements.patch: Dropped
  - d/p/patch-default-config-file.patch: Rebased

[ James Page ]
* d/rules,control: Tweak unit test execution, add subunit to BD's.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
import testtools
18
18
from mock import MagicMock
 
19
from mock import patch
 
20
from oslo_utils import netutils
19
21
from trove.common.context import TroveContext
20
22
from trove.common.instance import ServiceStatuses
21
23
from trove.guestagent import volume
22
 
from trove.guestagent.common import operating_system
23
24
from trove.guestagent.datastore.experimental.couchdb import (
24
25
    service as couchdb_service)
25
26
from trove.guestagent.datastore.experimental.couchdb import (
52
53
        self.origin_mount_points = volume.VolumeDevice.mount_points
53
54
        self.origin_stop_db = couchdb_service.CouchDBApp.stop_db
54
55
        self.origin_start_db = couchdb_service.CouchDBApp.start_db
55
 
        self.original_get_ip = operating_system.get_ip_address
 
56
        self.original_get_ip = netutils.get_my_ipv4
56
57
        self.orig_make_host_reachable = (
57
58
            couchdb_service.CouchDBApp.make_host_reachable)
58
59
 
67
68
        volume.VolumeDevice.mount_points = self.origin_mount_points
68
69
        couchdb_service.CouchDBApp.stop_db = self.origin_stop_db
69
70
        couchdb_service.CouchDBApp.start_db = self.origin_start_db
70
 
        operating_system.get_ip_address = self.original_get_ip
 
71
        netutils.get_my_ipv4 = self.original_get_ip
71
72
        couchdb_service.CouchDBApp.make_host_reachable = (
72
73
            self.orig_make_host_reachable)
73
74
 
124
125
    def test_restart(self):
125
126
        mock_status = MagicMock()
126
127
        self.manager.appStatus = mock_status
127
 
        couchdb_service.CouchDBApp.restart = MagicMock(return_value=None)
128
 
        #invocation
129
 
        self.manager.restart(self.context)
130
 
        #verification/assertion
131
 
        couchdb_service.CouchDBApp.restart.assert_any_call()
 
128
        with patch.object(couchdb_service.CouchDBApp, 'restart',
 
129
                          return_value=None):
 
130
            #invocation
 
131
            self.manager.restart(self.context)
 
132
            #verification/assertion
 
133
            couchdb_service.CouchDBApp.restart.assert_any_call()
132
134
 
133
135
    def test_stop_db(self):
134
136
        mock_status = MagicMock()
139
141
        #verification/assertion
140
142
        couchdb_service.CouchDBApp.stop_db.assert_any_call(
141
143
            do_not_start_on_reboot=False)
 
144
 
 
145
    def test_rpc_ping(self):
 
146
        output = self.manager.rpc_ping(self.context)
 
147
        self.assertEqual(output, True)