def test_refresh_lazy_resource(self): connector = mock.Mock(spec=Connector) r = Resource(connector, oid="id") r.refresh() assert r._is_stub assert r._content == {"@odata.id": "id"} assert connector.get.call_count == 0
def test_refresh_eager_resource(self): connector = mock.Mock(spec=Connector) connector.get.return_value = mock.MagicMock(status=200, json={ "@odata.id": "id", "a": "val", }) r = Resource(connector, oid="id", lazy=False) # first GET r.refresh() # second GET assert not r._is_stub assert r._content == {"@odata.id": "id", "a": "val"} assert connector.get.call_count == 2