Skip to content

Commit bd59283

Browse files
committed
Expect APIError, not ClientError
Cleanup following on from gh-590. Also removes assertions about error messages from CLI tests as these will be constructed by the API server.
1 parent 115832f commit bd59283

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

tests/integration/test_subscriptions_api.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44

55
import planet.clients.subscriptions
66
from planet.clients.subscriptions import SubscriptionsClient
7-
from planet.exceptions import ClientError
7+
from planet.exceptions import APIError
88
from planet.http import Session
99

1010

1111
@pytest.mark.xfail(reason="Client/server interaction not yet implemented")
1212
@pytest.mark.asyncio
1313
async def test_list_subscriptions_failure(monkeypatch):
14-
"""ClientError is raised if there is a server error."""
14+
"""APIError is raised if there is a server error."""
1515
monkeypatch.setattr(planet.clients.subscriptions, "_fake_subs", 0)
16-
with pytest.raises(ClientError):
16+
with pytest.raises(APIError):
1717
async with Session() as session:
1818
client = SubscriptionsClient(session)
1919
_ = [sub async for sub in client.list_subscriptions()]
@@ -41,9 +41,9 @@ async def test_list_subscriptions_success(status, count, monkeypatch):
4141
@pytest.mark.xfail(reason="Client/server interaction not yet implemented")
4242
@pytest.mark.asyncio
4343
async def test_create_subscription_failure(monkeypatch):
44-
"""ClientError is raised if there is a server error."""
44+
"""APIError is raised if there is a server error."""
4545
monkeypatch.setattr(planet.clients.subscriptions, "_fake_subs", {})
46-
with pytest.raises(ClientError):
46+
with pytest.raises(APIError):
4747
async with Session() as session:
4848
client = SubscriptionsClient(session)
4949
_ = await client.create_subscription({"lol": "wut"})
@@ -65,9 +65,9 @@ async def test_create_subscription_success(monkeypatch):
6565
@pytest.mark.xfail(reason="Client/server interaction not yet implemented")
6666
@pytest.mark.asyncio
6767
async def test_cancel_subscription_failure(monkeypatch):
68-
"""ClientError is raised if there is a server error."""
68+
"""APIError is raised if there is a server error."""
6969
monkeypatch.setattr(planet.clients.subscriptions, "_fake_subs", {})
70-
with pytest.raises(ClientError):
70+
with pytest.raises(APIError):
7171
async with Session() as session:
7272
client = SubscriptionsClient(session)
7373
_ = await client.cancel_subscription("lolwut")
@@ -93,9 +93,9 @@ async def test_cancel_subscription_success(monkeypatch):
9393
@pytest.mark.xfail(reason="Client/server interaction not yet implemented")
9494
@pytest.mark.asyncio
9595
async def test_update_subscription_failure(monkeypatch):
96-
"""ClientError is raised if there is a server error."""
96+
"""APIError is raised if there is a server error."""
9797
monkeypatch.setattr(planet.clients.subscriptions, "_fake_subs", {})
98-
with pytest.raises(ClientError):
98+
with pytest.raises(APIError):
9999
async with Session() as session:
100100
client = SubscriptionsClient(session)
101101
_ = await client.update_subscription("lolwut", {})
@@ -124,9 +124,9 @@ async def test_update_subscription_success(monkeypatch):
124124
@pytest.mark.xfail(reason="Client/server interaction not yet implemented")
125125
@pytest.mark.asyncio
126126
async def test_get_subscription_failure(monkeypatch):
127-
"""ClientError is raised if there is a server error."""
127+
"""APIError is raised if there is a server error."""
128128
monkeypatch.setattr(planet.clients.subscriptions, "_fake_subs", {})
129-
with pytest.raises(ClientError):
129+
with pytest.raises(APIError):
130130
async with Session() as session:
131131
client = SubscriptionsClient(session)
132132
_ = await client.get_subscription("lolwut")
@@ -152,9 +152,9 @@ async def test_get_subscription_success(monkeypatch):
152152
@pytest.mark.xfail(reason="Client/server interaction not yet implemented")
153153
@pytest.mark.asyncio
154154
async def test_get_results_failure(monkeypatch):
155-
"""ClientError is raised if there is a server error."""
155+
"""APIError is raised if there is a server error."""
156156
monkeypatch.setattr(planet.clients.subscriptions, "_fake_sub_results", {})
157-
with pytest.raises(ClientError):
157+
with pytest.raises(APIError):
158158
async with Session() as session:
159159
client = SubscriptionsClient(session)
160160
_ = [res async for res in client.get_results("lolwut")]

tests/integration/test_subscriptions_cli.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ def test_subscriptions_create_failure(monkeypatch, subscription_count):
9898
catch_exceptions=True)
9999

100100
assert result.exit_code == 1 # failure.
101-
assert "Subscription failure" in result.output
102101
assert subscription_count() == 0
103102

104103

@@ -131,7 +130,6 @@ def test_subscriptions_create_success(cmd_arg,
131130
catch_exceptions=True)
132131

133132
assert result.exit_code == 0 # success.
134-
assert "Request lacks required members" not in result.output
135133
assert uuid.UUID(json.loads(result.output)['id'])
136134
assert subscription_count() == 1
137135

@@ -174,7 +172,6 @@ def test_subscriptions_cancel_failure(monkeypatch):
174172
catch_exceptions=True)
175173

176174
assert result.exit_code == 1 # failure.
177-
assert "Subscription failure" in result.output
178175

179176

180177
def test_subscriptions_cancel_success(monkeypatch, subscription_count):
@@ -213,7 +210,6 @@ def test_subscriptions_update_failure(monkeypatch):
213210
catch_exceptions=True)
214211

215212
assert result.exit_code == 1 # failure.
216-
assert "Subscription failure" in result.output
217213

218214

219215
def test_subscriptions_update_success(monkeypatch):
@@ -251,7 +247,6 @@ def test_subscriptions_describe_failure(monkeypatch):
251247
catch_exceptions=True)
252248

253249
assert result.exit_code == 1 # failure.
254-
assert "Subscription failure" in result.output
255250

256251

257252
def test_subscriptions_describe_success(monkeypatch):

0 commit comments

Comments
 (0)