Skip to content

Commit

Permalink
Use mock.sentinel.session in favour of mock.Mock()
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Collard <adam.collard@canonical.com>
  • Loading branch information
sparkiegeek committed Feb 17, 2023
1 parent ba8f06f commit 7949f97
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pylxd/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,13 +458,13 @@ class TestAPINode(TestCase):

def test_getattr(self):
"""API Nodes can use object notation for nesting."""
node = client._APINode("http://test.com", mock.Mock())
node = client._APINode("http://test.com", mock.sentinel.session)
new_node = node.test
self.assertEqual("http://test.com/test", new_node._api_endpoint)

def test_getattr_storage_pools(self):
"""API node with storage_pool should be storage-pool"""
node = client._APINode("http://test.com", mock.Mock())
node = client._APINode("http://test.com", mock.sentinel.session)
new_node = node.test.storage_pools
self.assertEqual("http://test.com/test/storage-pools", new_node._api_endpoint)
# other _ should stay as they were.
Expand All @@ -473,15 +473,15 @@ def test_getattr_storage_pools(self):

def test_getitem(self):
"""API Nodes can use dict notation for nesting."""
node = client._APINode("http://test.com", mock.Mock())
node = client._APINode("http://test.com", mock.sentinel.session)
new_node = node["test"]
self.assertEqual("http://test.com/test", new_node._api_endpoint)

def test_getitem_leave_underscores_alone(self):
"""Bug 295 erronously changed underscores to '-' -- let's make sure
it doens't happend again
"""
node = client._APINode("http://test.com", mock.Mock())
node = client._APINode("http://test.com", mock.sentinel.session)
new_node = node.thing["my_snapshot"]
self.assertEqual("http://test.com/thing/my_snapshot", new_node._api_endpoint)

Expand All @@ -493,7 +493,7 @@ def test_session(self):

def test_session_passed_to_child(self):
"""session should be shared across path traversl"""
parent_node = client._APINode("http+unix://test.com", mock.Mock())
parent_node = client._APINode("http+unix://test.com", mock.sentinel.session)
child_node = parent_node.instances
self.assertIs(parent_node.session, child_node.session)

Expand Down

0 comments on commit 7949f97

Please sign in to comment.