Skip to content

Commit b39dfd7

Browse files
committed
Fix acceptance tests
1 parent 663142f commit b39dfd7

File tree

4 files changed

+80
-4
lines changed

4 files changed

+80
-4
lines changed

.github/workflows/run-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ jobs:
8787
8888
pip3 install --user --ignore-installed -r requirements-dev.txt
8989
behave --junit tests/acceptance/pam
90-
behave --junit tests/acceptance/encryption/cryptor-module.feature -t=~na=python -k
90+
behave --junit tests/acceptance/encryption/cryptor-module.feature -t=~na=python
9191
behave --junit tests/acceptance/subscribe
9292
- name: Expose acceptance tests reports
9393
uses: actions/upload-artifact@v4

pubnub/event_engine/models/states.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ def reconnect_failure(self, event: events.ReceiveReconnectFailureEvent, context:
568568
return PNTransition(
569569
state=ReceiveReconnectingState,
570570
context=self._context,
571-
invocation=invocations.EmitStatusInvocation(PNStatusCategory.UnexpectedDisconnectCategory,
571+
invocation=invocations.EmitStatusInvocation(PNStatusCategory.PNUnexpectedDisconnectCategory,
572572
operation=PNOperationType.PNSubscribeOperation,
573573
context=self._context)
574574
)

tests/acceptance/pam/steps/then_steps.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
from behave import then
3+
34
from pubnub.exceptions import PubNubException
45

56

@@ -19,6 +20,12 @@ def step_impl(context, channel):
1920
assert context.token_resource
2021

2122

23+
@then("token {data_type} permission {permission}")
24+
def step_impl(context, data_type, permission):
25+
assert context.token_resource
26+
assert context.token_resource[permission.lower()]
27+
28+
2229
@then("the token contains the authorized UUID {test_uuid}")
2330
def step_impl(context, test_uuid):
2431
assert context.parsed_token.get("authorized_uuid") == test_uuid.strip('"')
@@ -80,6 +87,75 @@ def step_impl(context):
8087
context.pam_call_error = json.loads(context.pam_call_result._errormsg)
8188

8289

90+
@then("the error status code is {error_code}")
91+
def step_impl(context, error_code):
92+
assert context.pam_call_error['status'] == int(error_code)
93+
94+
95+
@then("the auth error message is '{error_message}'")
96+
@then("the error message is '{error_message}'")
97+
def step_impl(context, error_message):
98+
if 'message' in context.pam_call_error:
99+
assert context.pam_call_error['message'] == error_message
100+
elif 'error' in context.pam_call_error and 'message' in context.pam_call_error['error']:
101+
assert context.pam_call_error['error']['message'] == error_message
102+
else:
103+
raise AssertionError("Unexpected payload: {}".format(context.pam_call_error))
104+
105+
106+
@then("the error detail message is not empty")
107+
def step_impl(context):
108+
if 'error' in context.pam_call_error and 'details' in context.pam_call_error['error']:
109+
assert len(context.pam_call_error['error']['details']) > 0
110+
assert 'message' in context.pam_call_error['error']['details'][0]
111+
assert len(context.pam_call_error['error']['details'][0]['message']) > 0
112+
else:
113+
raise AssertionError("Unexpected payload: {}".format(context.pam_call_error))
114+
115+
116+
@then("the error detail message is '{details_message}'")
117+
def step_impl(context, details_message):
118+
if 'error' in context.pam_call_error and 'details' in context.pam_call_error['error']:
119+
assert len(context.pam_call_error['error']['details']) > 0
120+
assert 'message' in context.pam_call_error['error']['details'][0]
121+
assert context.pam_call_error['error']['details'][0]['message'] == details_message
122+
else:
123+
raise AssertionError("Unexpected payload: {}".format(context.pam_call_error))
124+
125+
126+
@then("the error detail location is '{details_location}'")
127+
def step_impl(context, details_location):
128+
if 'error' in context.pam_call_error and 'details' in context.pam_call_error['error']:
129+
assert len(context.pam_call_error['error']['details']) > 0
130+
assert 'location' in context.pam_call_error['error']['details'][0]
131+
assert context.pam_call_error['error']['details'][0]['location'] == details_location
132+
else:
133+
raise AssertionError("Unexpected payload: {}".format(context.pam_call_error))
134+
135+
136+
@then("the error detail location type is '{details_location_type}'")
137+
def step_impl(context, details_location_type):
138+
if 'error' in context.pam_call_error and 'details' in context.pam_call_error['error']:
139+
assert len(context.pam_call_error['error']['details']) > 0
140+
assert 'locationType' in context.pam_call_error['error']['details'][0]
141+
assert context.pam_call_error['error']['details'][0]['locationType'] == details_location_type
142+
else:
143+
raise AssertionError("Unexpected payload: {}".format(context.pam_call_error))
144+
145+
146+
@then("the error service is '{error_service}'")
147+
def step_impl(context, error_service):
148+
assert context.pam_call_error['service'] == error_service
149+
150+
151+
@then("the error source is '{error_source}'")
152+
def step_impl(context, error_source):
153+
if 'error' in context.pam_call_error and 'source' in context.pam_call_error['error']:
154+
assert context.pam_call_error['error']['source'] == error_source
155+
else:
156+
raise AssertionError("Unexpected payload: {}".format(context.pam_call_error))
157+
158+
83159
@then("the result is successful")
84160
def step_impl(context):
85161
assert context.publish_result.result.timetoken

tests/acceptance/subscribe/steps/then_steps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ async def step_impl(ctx: PNContext):
2525
await ctx.pubnub.stop()
2626

2727

28-
@then("I observe the following")
28+
@then("I observe the following:")
2929
@async_run_until_complete
3030
async def step_impl(ctx):
3131
def parse_log_line(line: str):
@@ -74,7 +74,7 @@ async def step_impl(ctx: PNContext, wait_time: str):
7474
await asyncio.sleep(int(wait_time))
7575

7676

77-
@then(u'I observe the following Events and Invocations of the Presence EE')
77+
@then(u'I observe the following Events and Invocations of the Presence EE:')
7878
@async_run_until_complete
7979
async def step_impl(ctx):
8080
def parse_log_line(line: str):

0 commit comments

Comments
 (0)