From 13d837739d1282e4071aa1d0925593ce517fdffa Mon Sep 17 00:00:00 2001 From: "John L. Villalovos" Date: Wed, 26 Jul 2017 10:23:43 -0700 Subject: [PATCH] Update some tests to copy the dictionaries passed in When doing a test, we should not pass a dictionary to a function and then use that same dictionary to check to make sure results match. Since the called function can modify the dictionary and our test will pass with a modified dictionary. Change-Id: Ic3b29d2f05e3b2a05b9dd25a2d2d2f682c79a0f9 --- sushy/tests/unit/test_connector.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sushy/tests/unit/test_connector.py b/sushy/tests/unit/test_connector.py index 3586175b..760c1f28 100644 --- a/sushy/tests/unit/test_connector.py +++ b/sushy/tests/unit/test_connector.py @@ -35,19 +35,22 @@ class ConnectorMethodsTestCase(base.TestCase): @mock.patch.object(connector.Connector, '_op', autospec=True) def test_get(self, mock__op): - self.conn.get(path='fake/path', data=self.data, headers=self.headers) + self.conn.get(path='fake/path', data=self.data.copy(), + headers=self.headers.copy()) mock__op.assert_called_once_with(mock.ANY, 'GET', 'fake/path', self.data, self.headers) @mock.patch.object(connector.Connector, '_op', autospec=True) def test_post(self, mock__op): - self.conn.post(path='fake/path', data=self.data, headers=self.headers) + self.conn.post(path='fake/path', data=self.data.copy(), + headers=self.headers.copy()) mock__op.assert_called_once_with(mock.ANY, 'POST', 'fake/path', self.data, self.headers) @mock.patch.object(connector.Connector, '_op', autospec=True) def test_patch(self, mock__op): - self.conn.patch(path='fake/path', data=self.data, headers=self.headers) + self.conn.patch(path='fake/path', data=self.data.copy(), + headers=self.headers.copy()) mock__op.assert_called_once_with(mock.ANY, 'PATCH', 'fake/path', self.data, self.headers) @@ -85,7 +88,7 @@ class ConnectorOpTestCase(base.TestCase): expected_headers = self.headers.copy() expected_headers['Content-Type'] = 'application/json' - self.conn._op('POST', path='fake/path', data=self.data, + self.conn._op('POST', path='fake/path', data=self.data.copy(), headers=self.headers) self.request.assert_called_once_with( 'POST', 'http://foo.bar:1234/fake/path',