summaryrefslogtreecommitdiff
path: root/neutronclient/tests
diff options
context:
space:
mode:
authorHongbin Lu <hongbin.lu@huawei.com>2018-03-16 18:42:40 +0000
committerSlawek Kaplonski <slawek@kaplonski.pl>2018-03-24 07:44:38 +0000
commit260f74308e3c78d3e1561280578f03cb5612ff4f (patch)
tree71294b2355cf6a089065045884daae8443632d4b /neutronclient/tests
parent8dac1afd43481d9c9ffcde3674eed3f7c64896ab (diff)
downloadpython-neutronclient-260f74308e3c78d3e1561280578f03cb5612ff4f.tar.gz
Remove mox/mox3 usage from fw modules
Change-Id: I913993c0bff15df19bf3978ed36062f970eef538 Partial-Bug: #1753504
Diffstat (limited to 'neutronclient/tests')
-rw-r--r--neutronclient/tests/unit/fw/test_cli20_firewallpolicy.py52
1 files changed, 27 insertions, 25 deletions
diff --git a/neutronclient/tests/unit/fw/test_cli20_firewallpolicy.py b/neutronclient/tests/unit/fw/test_cli20_firewallpolicy.py
index 1b425e6..874ec72 100644
--- a/neutronclient/tests/unit/fw/test_cli20_firewallpolicy.py
+++ b/neutronclient/tests/unit/fw/test_cli20_firewallpolicy.py
@@ -16,7 +16,7 @@
import sys
-from mox3 import mox
+import mock
from neutronclient.neutron.v2_0.fw import firewallpolicy
from neutronclient import shell
@@ -166,24 +166,25 @@ class CLITestV20FirewallPolicyJSON(test_cli20.CLITestV20Base):
'insert_before': 'rule2',
'insert_after': 'rule1'}
- self.mox.StubOutWithMock(cmd, "get_client")
- self.mox.StubOutWithMock(self.client.httpclient, "request")
- cmd.get_client().MultipleTimes().AndReturn(self.client)
body = extrafields
path = getattr(self.client, resource + "_insert_path")
- self.client.httpclient.request(
+ cmd_parser = cmd.get_parser(resource + "_insert_rule")
+ resp = (test_cli20.MyResp(204), None)
+
+ with mock.patch.object(cmd, "get_client",
+ return_value=self.client) as mock_get_client, \
+ mock.patch.object(self.client.httpclient, "request",
+ return_value=resp) as mock_request:
+ shell.run_command(cmd, cmd_parser, args)
+ self.assert_mock_multiple_calls_with_same_arguments(
+ mock_get_client, mock.call(), 4)
+ mock_request.assert_called_once_with(
test_cli20.MyUrlComparator(
test_cli20.end_url(path % myid),
self.client),
'PUT', body=test_cli20.MyComparator(body, self.client),
- headers=mox.ContainsKeyValue(
- 'X-Auth-Token',
- test_cli20.TOKEN)).AndReturn((test_cli20.MyResp(204), None))
- self.mox.ReplayAll()
- cmd_parser = cmd.get_parser(resource + "_insert_rule")
- shell.run_command(cmd, cmd_parser, args)
- self.mox.VerifyAll()
- self.mox.UnsetStubs()
+ headers=test_cli20.ContainsKeyValue(
+ {'X-Auth-Token': test_cli20.TOKEN}))
def test_remove_firewall_rule(self):
# firewall-policy-remove-rule myid ruleid
@@ -195,24 +196,25 @@ class CLITestV20FirewallPolicyJSON(test_cli20.CLITestV20Base):
args = ['myid', 'removerule']
extrafields = {'firewall_rule_id': 'removerule', }
- self.mox.StubOutWithMock(cmd, "get_client")
- self.mox.StubOutWithMock(self.client.httpclient, "request")
- cmd.get_client().MultipleTimes().AndReturn(self.client)
body = extrafields
path = getattr(self.client, resource + "_remove_path")
- self.client.httpclient.request(
+ cmd_parser = cmd.get_parser(resource + "_remove_rule")
+ resp = (test_cli20.MyResp(204), None)
+
+ with mock.patch.object(cmd, "get_client",
+ return_value=self.client) as mock_get_client, \
+ mock.patch.object(self.client.httpclient, "request",
+ return_value=resp) as mock_request:
+ shell.run_command(cmd, cmd_parser, args)
+ self.assert_mock_multiple_calls_with_same_arguments(
+ mock_get_client, mock.call(), 2)
+ mock_request.assert_called_once_with(
test_cli20.MyUrlComparator(
test_cli20.end_url(path % myid),
self.client),
'PUT', body=test_cli20.MyComparator(body, self.client),
- headers=mox.ContainsKeyValue(
- 'X-Auth-Token',
- test_cli20.TOKEN)).AndReturn((test_cli20.MyResp(204), None))
- self.mox.ReplayAll()
- cmd_parser = cmd.get_parser(resource + "_remove_rule")
- shell.run_command(cmd, cmd_parser, args)
- self.mox.VerifyAll()
- self.mox.UnsetStubs()
+ headers=test_cli20.ContainsKeyValue(
+ {'X-Auth-Token': test_cli20.TOKEN}))
def test_update_firewall_policy_name_shared_audited(self):
# firewall-policy-update myid --name newname2 --shared --audited