Skip to content

Commit 0ea2561

Browse files
committed
Fixed tests
1 parent d047c5f commit 0ea2561

File tree

10 files changed

+5111
-4992
lines changed

10 files changed

+5111
-4992
lines changed

pubnub/endpoints/file_operations/publish_file_message.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def message_type(self, message_type: Union[PNMessageType, str]):
5858
return self
5959

6060
def space_id(self, space_id):
61-
self._space_id = str(space_id)
61+
self._space_id = space_id
6262
return self
6363

6464
def _encrypt_message(self, message):
@@ -99,10 +99,10 @@ def custom_params(self):
9999
"ttl": self._ttl,
100100
"store": 1 if self._should_store else 0
101101
})
102-
if self._message_type is not None:
102+
if self._message_type:
103103
params['type'] = str(self._message_type)
104104

105-
if self._space_id is not None:
105+
if self._space_id:
106106
params['space-id'] = str(self._space_id)
107107

108108
return params

pubnub/endpoints/file_operations/send_file.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ def is_compressable(self):
7373

7474
def custom_params(self):
7575
params = {}
76-
if self._message_type is not None:
76+
if self._message_type:
7777
params['type'] = str(self._message_type)
7878

79-
if self._space_id is not None:
80-
params['space-id'] = str(self._space_id)
79+
if self._space_id:
80+
params['space-id'] = self._space_id
8181

8282
return params
8383

@@ -125,7 +125,7 @@ def message_type(self, message_type: Union[PNMessageType, str]):
125125
return self
126126

127127
def space_id(self, space_id):
128-
self._space_id = str(space_id)
128+
self._space_id = space_id
129129
return self
130130

131131
def create_response(self, envelope, data=None):

pubnub/models/consumer/message_type.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def from_response(message_type: str = None, pn_message_type: str = None):
2121
return PNMessageType(message_type).set_pn_message_type(pn_message_type)
2222

2323
def __str__(self) -> str:
24-
return self.message_type if self.message_type is not None else str(self.pn_message_type)
24+
return self.message_type if self.message_type else str(self.pn_message_type)
2525

2626
def toJSON(self) -> str:
2727
return str(self)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
{
2+
"version": 1,
3+
"interactions": [
4+
{
5+
"request": {
6+
"method": "GET",
7+
"uri": "https://ps.pndsn.com/publish/{PN_KEY_PUBLISH}/{PN_KEY_SUBSCRIBE}/0/fetch-messages-message-type/0/%22hey-type%22?seqn=1",
8+
"body": null,
9+
"headers": {
10+
"User-Agent": [
11+
"PubNub-Python/7.1.0"
12+
],
13+
"Accept-Encoding": [
14+
"gzip, deflate"
15+
],
16+
"Accept": [
17+
"*/*"
18+
],
19+
"Connection": [
20+
"keep-alive"
21+
]
22+
}
23+
},
24+
"response": {
25+
"status": {
26+
"code": 200,
27+
"message": "OK"
28+
},
29+
"headers": {
30+
"Date": [
31+
"Wed, 08 Mar 2023 14:34:08 GMT"
32+
],
33+
"Content-Length": [
34+
"30"
35+
],
36+
"Cache-Control": [
37+
"no-cache"
38+
],
39+
"Access-Control-Allow-Origin": [
40+
"*"
41+
],
42+
"Content-Type": [
43+
"text/javascript; charset=\"UTF-8\""
44+
],
45+
"Access-Control-Allow-Methods": [
46+
"GET"
47+
],
48+
"Connection": [
49+
"keep-alive"
50+
]
51+
},
52+
"body": {
53+
"string": "[1,\"Sent\",\"16782860489406273\"]"
54+
}
55+
}
56+
},
57+
{
58+
"request": {
59+
"method": "GET",
60+
"uri": "https://ps.pndsn.com/v3/history-with-actions/sub-key/{PN_KEY_SUBSCRIBE}/channel/fetch-messages-message-type?include_message_type=true&include_meta=false&include_type=true&max=25",
61+
"body": null,
62+
"headers": {
63+
"User-Agent": [
64+
"PubNub-Python/7.1.0"
65+
],
66+
"Accept-Encoding": [
67+
"gzip, deflate"
68+
],
69+
"Accept": [
70+
"*/*"
71+
],
72+
"Connection": [
73+
"keep-alive"
74+
]
75+
}
76+
},
77+
"response": {
78+
"status": {
79+
"code": 200,
80+
"message": "OK"
81+
},
82+
"headers": {
83+
"Date": [
84+
"Wed, 08 Mar 2023 14:34:18 GMT"
85+
],
86+
"Content-Length": [
87+
"192"
88+
],
89+
"Access-Control-Allow-Origin": [
90+
"*"
91+
],
92+
"Cache-Control": [
93+
"no-cache"
94+
],
95+
"Accept-Ranges": [
96+
"bytes"
97+
],
98+
"Content-Type": [
99+
"text/javascript; charset=\"UTF-8\""
100+
],
101+
"Access-Control-Allow-Methods": [
102+
"GET, POST, DELETE, OPTIONS"
103+
],
104+
"Age": [
105+
"0"
106+
],
107+
"Access-Control-Allow-Credentials": [
108+
"true"
109+
],
110+
"Connection": [
111+
"keep-alive"
112+
]
113+
},
114+
"body": {
115+
"string": "{\"status\": 200, \"channels\": {\"fetch-messages-message-type\": [{\"message_type\": null, \"message\": \"hey-type\", \"timetoken\": \"16782860489406273\", \"type\": \"\"}]}, \"error_message\": \"\", \"error\": false}"
116+
}
117+
}
118+
}
119+
]
120+
}

tests/integrational/fixtures/native_sync/fetch_messages/include_meta.json

+36-36
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,30 @@
2727
"message": "OK"
2828
},
2929
"headers": {
30+
"Access-Control-Allow-Origin": [
31+
"*"
32+
],
3033
"Connection": [
3134
"keep-alive"
3235
],
33-
"Cache-Control": [
34-
"no-cache"
35-
],
36-
"Date": [
37-
"Tue, 07 Feb 2023 13:36:58 GMT"
38-
],
3936
"Content-Type": [
4037
"text/javascript; charset=\"UTF-8\""
4138
],
39+
"Date": [
40+
"Wed, 08 Mar 2023 13:58:47 GMT"
41+
],
4242
"Access-Control-Allow-Methods": [
4343
"GET"
4444
],
45+
"Cache-Control": [
46+
"no-cache"
47+
],
4548
"Content-Length": [
4649
"30"
47-
],
48-
"Access-Control-Allow-Origin": [
49-
"*"
5050
]
5151
},
5252
"body": {
53-
"string": "[1,\"Sent\",\"16757770188780189\"]"
53+
"string": "[1,\"Sent\",\"16782839273993377\"]"
5454
}
5555
}
5656
},
@@ -80,37 +80,37 @@
8080
"message": "OK"
8181
},
8282
"headers": {
83+
"Access-Control-Allow-Origin": [
84+
"*"
85+
],
8386
"Connection": [
8487
"keep-alive"
8588
],
86-
"Cache-Control": [
87-
"no-cache"
88-
],
89-
"Date": [
90-
"Tue, 07 Feb 2023 13:36:58 GMT"
91-
],
9289
"Content-Type": [
9390
"text/javascript; charset=\"UTF-8\""
9491
],
92+
"Date": [
93+
"Wed, 08 Mar 2023 13:58:47 GMT"
94+
],
9595
"Access-Control-Allow-Methods": [
9696
"GET"
9797
],
98+
"Cache-Control": [
99+
"no-cache"
100+
],
98101
"Content-Length": [
99102
"30"
100-
],
101-
"Access-Control-Allow-Origin": [
102-
"*"
103103
]
104104
},
105105
"body": {
106-
"string": "[1,\"Sent\",\"16757770189120588\"]"
106+
"string": "[1,\"Sent\",\"16782839274412428\"]"
107107
}
108108
}
109109
},
110110
{
111111
"request": {
112112
"method": "GET",
113-
"uri": "https://ps.pndsn.com/v3/history-with-actions/sub-key/{PN_KEY_SUBSCRIBE}/channel/fetch-messages-actions-meta-2?include_message_type=true&include_meta=true&max=25",
113+
"uri": "https://ps.pndsn.com/v3/history-with-actions/sub-key/{PN_KEY_SUBSCRIBE}/channel/fetch-messages-actions-meta-2?include_message_type=true&include_meta=true&include_type=true&max=25",
114114
"body": null,
115115
"headers": {
116116
"User-Agent": [
@@ -133,39 +133,39 @@
133133
"message": "OK"
134134
},
135135
"headers": {
136+
"Access-Control-Allow-Origin": [
137+
"*"
138+
],
139+
"Transfer-Encoding": [
140+
"chunked"
141+
],
136142
"Connection": [
137143
"keep-alive"
138144
],
139145
"Content-Encoding": [
140146
"gzip"
141147
],
142-
"Cache-Control": [
143-
"no-cache"
144-
],
145-
"Access-Control-Allow-Credentials": [
146-
"true"
147-
],
148-
"Date": [
149-
"Tue, 07 Feb 2023 13:37:08 GMT"
150-
],
151148
"Content-Type": [
152149
"text/javascript; charset=\"UTF-8\""
153150
],
151+
"Date": [
152+
"Wed, 08 Mar 2023 13:58:47 GMT"
153+
],
154154
"Access-Control-Allow-Methods": [
155155
"GET, POST, DELETE, OPTIONS"
156156
],
157-
"Access-Control-Allow-Origin": [
158-
"*"
159-
],
160157
"Age": [
161158
"0"
162159
],
163-
"Transfer-Encoding": [
164-
"chunked"
160+
"Access-Control-Allow-Credentials": [
161+
"true"
162+
],
163+
"Cache-Control": [
164+
"no-cache"
165165
]
166166
},
167167
"body": {
168-
"binary": "H4sIAAAAAAAAA5SOwQqDQAxEf0VydkEFu2t/pRRJJa2LdpVNPIj4783aHnpsL4HMTPJmAxaUheGcVUWRZ9D1GAKNSdjgTtL15knM+CA22ImfAqsgaCpNXDb4mLpAT+thgb4Rr6FpoJCM8mRra21ROmedziYlPoetrDNpKCzjeKiCum3g2UjvUw0Y4sKymiHiDfY9V/M/aFNWRe3cD9BENG/ojBJ9NyjwqkigGKfYfnHTt0PUhnccmfYXAAAA//8DAJSWFOFLAQAA"
168+
"binary": "H4sIAAAAAAAAA6RPSwqDQAy9SsnaAT+gY69SiqQS66AdyyQuRLx7M9aFy0J3ycv7ZQUWlJnhesnTNLlA26P3NEZghY6k7c2LmPFJbLAVN3lWQNDkyritIMubdAJQ7UGMa0/LTouwOBVMA/l4yMrK5qWtyswWNiuK7CRsDjM/j+NuJ6iSFRwb6V2sBEOYWRYzBHzAtiV6/KNAlVe2rn8oENPNt8AbJbh20PC7xgOFMIXm9Hh020Ft2+HItH0AAAD//wMAQWkka2MBAAA="
169169
}
170170
}
171171
}

0 commit comments

Comments
 (0)