open-space-toolkit-io 4.1.0__py313-none-manylinux2014_x86_64.whl
Sign up to get free protection for your applications and to get access to all the features.
- open_space_toolkit_io-4.1.0.dist-info/METADATA +27 -0
- open_space_toolkit_io-4.1.0.dist-info/RECORD +23 -0
- open_space_toolkit_io-4.1.0.dist-info/WHEEL +5 -0
- open_space_toolkit_io-4.1.0.dist-info/top_level.txt +1 -0
- open_space_toolkit_io-4.1.0.dist-info/zip-safe +1 -0
- ostk/__init__.py +1 -0
- ostk/io/OpenSpaceToolkitIOPy.cpython-313-x86_64-linux-gnu.so +0 -0
- ostk/io/__init__.py +5 -0
- ostk/io/__init__.pyi +121 -0
- ostk/io/ip/__init__.pyi +3 -0
- ostk/io/ip/tcp/__init__.pyi +3 -0
- ostk/io/ip/tcp/http.pyi +360 -0
- ostk/io/libopen-space-toolkit-io.so.4 +0 -0
- ostk/io/py.typed +0 -0
- ostk/io/test/__init__.py +1 -0
- ostk/io/test/ip/__init__.py +1 -0
- ostk/io/test/ip/tcp/__init__.py +1 -0
- ostk/io/test/ip/tcp/http/__init__.py +1 -0
- ostk/io/test/ip/tcp/http/test_client.py +60 -0
- ostk/io/test/ip/tcp/http/test_request.py +90 -0
- ostk/io/test/ip/tcp/http/test_response.py +198 -0
- ostk/io/test/url/__init__.py +1 -0
- ostk/io/test/url/test_url.py +157 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
Metadata-Version: 2.2
|
2
|
+
Name: open-space-toolkit-io
|
3
|
+
Version: 4.1.0
|
4
|
+
Summary: Addressing, networking, database connectors.
|
5
|
+
Author: Open Space Collective
|
6
|
+
Author-email: contact@open-space-collective.org
|
7
|
+
License: Apache License 2.0
|
8
|
+
Keywords: open-space-collective,open-space-toolkit io
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
11
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
12
|
+
Classifier: Operating System :: POSIX :: Linux
|
13
|
+
Description-Content-Type: text/markdown
|
14
|
+
Requires-Dist: open-space-toolkit-core~=5.0
|
15
|
+
|
16
|
+
# Open Space Toolkit ▸ I/O
|
17
|
+
|
18
|
+
Addressing, networking, database connectors.
|
19
|
+
|
20
|
+
[![Build and Test](https://github.com/open-space-collective/open-space-toolkit-io/actions/workflows/build-test.yml/badge.svg?branch=main)](https://github.com/open-space-collective/open-space-toolkit-io/actions/workflows/build-test.yml)
|
21
|
+
[![Code Coverage](https://codecov.io/gh/open-space-collective/open-space-toolkit-io/branch/main/graph/badge.svg)](https://codecov.io/gh/open-space-collective/open-space-toolkit-io)
|
22
|
+
[![Documentation](https://img.shields.io/readthedocs/pip/stable.svg)](https://open-space-collective.github.io/open-space-toolkit-io)
|
23
|
+
[![GitHub version](https://badge.fury.io/gh/open-space-collective%2Fopen-space-toolkit-io.svg)](https://badge.fury.io/gh/open-space-collective%2Fopen-space-toolkit-io)
|
24
|
+
[![PyPI version](https://badge.fury.io/py/open-space-toolkit-io.svg)](https://badge.fury.io/py/open-space-toolkit-io)
|
25
|
+
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
|
26
|
+
|
27
|
+
[GitHub](https://github.com/open-space-collective/open-space-toolkit-io)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
ostk/__init__.py,sha256=epnVn2PwdQkUDZ1msqBRO5nEZIOUBIq-IfK3IlNPijE,21
|
2
|
+
ostk/io/OpenSpaceToolkitIOPy.cpython-313-x86_64-linux-gnu.so,sha256=dwGYyzC4m1Fbm3QDO9pRgfNr0JXUfUJcbGdfdcFjFQY,343960
|
3
|
+
ostk/io/__init__.py,sha256=IpLxatW_R2ItRy031KQcbFRNczGDpWeozg9COJH9QLA,83
|
4
|
+
ostk/io/__init__.pyi,sha256=2lp-McMB99MvB-ZUN2JRNty-dR7nCo_2An5SMy_hcUQ,4228
|
5
|
+
ostk/io/libopen-space-toolkit-io.so.4,sha256=JM-Dm33RYszqItkvRmdOBZDeR50HPkmODeCm1PzfWD0,6543096
|
6
|
+
ostk/io/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
|
+
ostk/io/ip/__init__.pyi,sha256=ntQD1UC6c2PBCdh6GvoNKWokhgW_xxseXUcnImkj5lk,71
|
8
|
+
ostk/io/ip/tcp/__init__.pyi,sha256=anAZsqaIIFk6JO4RSLxWienbBdxMFWXmjlpNgx_obyk,73
|
9
|
+
ostk/io/ip/tcp/http.pyi,sha256=8izOVEG_Y0wJW1lPN_lIqfkD5JUbuKVx-fFajyusb8A,17222
|
10
|
+
ostk/io/test/__init__.py,sha256=epnVn2PwdQkUDZ1msqBRO5nEZIOUBIq-IfK3IlNPijE,21
|
11
|
+
ostk/io/test/ip/__init__.py,sha256=epnVn2PwdQkUDZ1msqBRO5nEZIOUBIq-IfK3IlNPijE,21
|
12
|
+
ostk/io/test/ip/tcp/__init__.py,sha256=epnVn2PwdQkUDZ1msqBRO5nEZIOUBIq-IfK3IlNPijE,21
|
13
|
+
ostk/io/test/ip/tcp/http/__init__.py,sha256=epnVn2PwdQkUDZ1msqBRO5nEZIOUBIq-IfK3IlNPijE,21
|
14
|
+
ostk/io/test/ip/tcp/http/test_client.py,sha256=I0nRWp3HTkr2oMEbOSZJZEYVHxn7pbAdE6kBdI29mbU,1682
|
15
|
+
ostk/io/test/ip/tcp/http/test_request.py,sha256=-puxxwFqhzizeX8odF0gqgbRCXLk_zDCZkQuEUNJYx0,2205
|
16
|
+
ostk/io/test/ip/tcp/http/test_response.py,sha256=GAnbvAeNHJO9odmvxmZrW-ruuCHLYI-xYMJFQAE41lw,5866
|
17
|
+
ostk/io/test/url/__init__.py,sha256=epnVn2PwdQkUDZ1msqBRO5nEZIOUBIq-IfK3IlNPijE,21
|
18
|
+
ostk/io/test/url/test_url.py,sha256=9mPqkSq_9Xrqtdl-dK8YWw2bkvo2zd63j03WEOU1VEs,4554
|
19
|
+
open_space_toolkit_io-4.1.0.dist-info/METADATA,sha256=1db1gdBjPpMpyxaqIzMCayhzy3ZVPrt8oUBcGeBdJeI,1669
|
20
|
+
open_space_toolkit_io-4.1.0.dist-info/WHEEL,sha256=tYxIONYs3ivmw21Nz6roIs7SUMlOyYL1781kzpAyrT8,110
|
21
|
+
open_space_toolkit_io-4.1.0.dist-info/top_level.txt,sha256=zOR18699uDYnafgarhL8WU_LmTZY_5NVqutv-flp_x4,5
|
22
|
+
open_space_toolkit_io-4.1.0.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
23
|
+
open_space_toolkit_io-4.1.0.dist-info/RECORD,,
|
@@ -0,0 +1 @@
|
|
1
|
+
ostk
|
@@ -0,0 +1 @@
|
|
1
|
+
|
ostk/__init__.py
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Apache License 2.0
|
Binary file
|
ostk/io/__init__.py
ADDED
ostk/io/__init__.pyi
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
from ostk import core as OpenSpaceToolkitCorePy
|
3
|
+
from ostk.core import container
|
4
|
+
from ostk.core import filesystem
|
5
|
+
from ostk.core import type
|
6
|
+
import ostk.core.type
|
7
|
+
from ostk import io as OpenSpaceToolkitIOPy
|
8
|
+
import typing
|
9
|
+
from . import ip
|
10
|
+
__all__ = ['OpenSpaceToolkitCorePy', 'OpenSpaceToolkitIOPy', 'URL', 'container', 'filesystem', 'ip', 'type']
|
11
|
+
class URL:
|
12
|
+
class Query:
|
13
|
+
class Parameter:
|
14
|
+
__hash__: typing.ClassVar[None] = None
|
15
|
+
@staticmethod
|
16
|
+
def _pybind11_conduit_v1_(*args, **kwargs):
|
17
|
+
...
|
18
|
+
def __eq__(self, arg0: URL.Query.Parameter) -> bool:
|
19
|
+
...
|
20
|
+
def __init__(self, arg0: ostk.core.type.String, arg1: ostk.core.type.String) -> None:
|
21
|
+
...
|
22
|
+
def __ne__(self, arg0: URL.Query.Parameter) -> bool:
|
23
|
+
...
|
24
|
+
def get_name(self) -> ostk.core.type.String:
|
25
|
+
...
|
26
|
+
def get_value(self) -> ostk.core.type.String:
|
27
|
+
...
|
28
|
+
def is_defined(self) -> bool:
|
29
|
+
...
|
30
|
+
__hash__: typing.ClassVar[None] = None
|
31
|
+
@staticmethod
|
32
|
+
def _pybind11_conduit_v1_(*args, **kwargs):
|
33
|
+
...
|
34
|
+
@staticmethod
|
35
|
+
def parse(arg0: ostk.core.type.String) -> URL.Query:
|
36
|
+
...
|
37
|
+
@staticmethod
|
38
|
+
def undefined() -> URL.Query:
|
39
|
+
...
|
40
|
+
def __eq__(self, arg0: URL.Query) -> bool:
|
41
|
+
...
|
42
|
+
def __init__(self, arg0: list[...]) -> None:
|
43
|
+
...
|
44
|
+
def __ne__(self, arg0: URL.Query) -> bool:
|
45
|
+
...
|
46
|
+
def __repr__(self) -> str:
|
47
|
+
...
|
48
|
+
def __str__(self) -> str:
|
49
|
+
...
|
50
|
+
def add_parameter(self, arg0: ...) -> None:
|
51
|
+
...
|
52
|
+
def get_parameter_with_name(self, arg0: ostk.core.type.String) -> ostk.core.type.String:
|
53
|
+
...
|
54
|
+
def has_parameter_with_name(self, arg0: ostk.core.type.String) -> bool:
|
55
|
+
...
|
56
|
+
def is_defined(self) -> bool:
|
57
|
+
...
|
58
|
+
def to_string(self) -> ostk.core.type.String:
|
59
|
+
...
|
60
|
+
__hash__: typing.ClassVar[None] = None
|
61
|
+
@staticmethod
|
62
|
+
def _pybind11_conduit_v1_(*args, **kwargs):
|
63
|
+
...
|
64
|
+
@staticmethod
|
65
|
+
def parse(arg0: ostk.core.type.String) -> URL:
|
66
|
+
...
|
67
|
+
@staticmethod
|
68
|
+
def undefined() -> URL:
|
69
|
+
...
|
70
|
+
def __add__(self, arg0: ostk.core.type.String) -> URL:
|
71
|
+
...
|
72
|
+
def __eq__(self, arg0: URL) -> bool:
|
73
|
+
...
|
74
|
+
def __iadd__(self, arg0: ostk.core.type.String) -> URL:
|
75
|
+
...
|
76
|
+
def __init__(self, arg0: ostk.core.type.String, arg1: ostk.core.type.String, arg2: ostk.core.type.String, arg3: ostk.core.type.Integer, arg4: ostk.core.type.String, arg5: ostk.core.type.String, arg6: ..., arg7: ostk.core.type.String) -> None:
|
77
|
+
...
|
78
|
+
def __ne__(self, arg0: URL) -> bool:
|
79
|
+
...
|
80
|
+
def __repr__(self) -> str:
|
81
|
+
...
|
82
|
+
def __str__(self) -> str:
|
83
|
+
...
|
84
|
+
def get_fragment(self) -> ostk.core.type.String:
|
85
|
+
...
|
86
|
+
def get_host(self) -> ostk.core.type.String:
|
87
|
+
...
|
88
|
+
def get_password(self) -> ostk.core.type.String:
|
89
|
+
...
|
90
|
+
def get_path(self) -> ostk.core.type.String:
|
91
|
+
...
|
92
|
+
def get_port(self) -> ostk.core.type.Integer:
|
93
|
+
...
|
94
|
+
def get_query(self) -> ...:
|
95
|
+
...
|
96
|
+
def get_scheme(self) -> ostk.core.type.String:
|
97
|
+
...
|
98
|
+
def get_user(self) -> ostk.core.type.String:
|
99
|
+
...
|
100
|
+
def is_defined(self) -> bool:
|
101
|
+
...
|
102
|
+
def set_array(self: list[URL.Query.Parameter]) -> None:
|
103
|
+
...
|
104
|
+
def set_fragment(self, arg0: ostk.core.type.String) -> None:
|
105
|
+
...
|
106
|
+
def set_host(self, arg0: ostk.core.type.String) -> None:
|
107
|
+
...
|
108
|
+
def set_password(self, arg0: ostk.core.type.String) -> None:
|
109
|
+
...
|
110
|
+
def set_path(self, arg0: ostk.core.type.String) -> None:
|
111
|
+
...
|
112
|
+
def set_port(self, arg0: ostk.core.type.Integer) -> None:
|
113
|
+
...
|
114
|
+
def set_query(self, arg0: ...) -> None:
|
115
|
+
...
|
116
|
+
def set_scheme(self, arg0: ostk.core.type.String) -> None:
|
117
|
+
...
|
118
|
+
def set_user(self, arg0: ostk.core.type.String) -> None:
|
119
|
+
...
|
120
|
+
def to_string(self, doSanitize: bool = False) -> ostk.core.type.String:
|
121
|
+
...
|
ostk/io/ip/__init__.pyi
ADDED
ostk/io/ip/tcp/http.pyi
ADDED
@@ -0,0 +1,360 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
import ostk.core.filesystem
|
3
|
+
import ostk.core.type
|
4
|
+
import ostk.io
|
5
|
+
import typing
|
6
|
+
__all__ = ['Client', 'Request', 'Response']
|
7
|
+
class Client:
|
8
|
+
@staticmethod
|
9
|
+
def _pybind11_conduit_v1_(*args, **kwargs):
|
10
|
+
...
|
11
|
+
@staticmethod
|
12
|
+
def fetch(url: ostk.io.URL, directory: ostk.core.filesystem.Directory, follow_count: int = 0) -> ostk.core.filesystem.File:
|
13
|
+
...
|
14
|
+
@staticmethod
|
15
|
+
def get(arg0: ostk.io.URL) -> Response:
|
16
|
+
...
|
17
|
+
@staticmethod
|
18
|
+
def list(arg0: ostk.io.URL, arg1: ostk.core.filesystem.File, arg2: bool) -> None:
|
19
|
+
...
|
20
|
+
@staticmethod
|
21
|
+
def send(arg0: Request) -> Response:
|
22
|
+
...
|
23
|
+
class Request:
|
24
|
+
class Method:
|
25
|
+
"""
|
26
|
+
Members:
|
27
|
+
|
28
|
+
Undefined
|
29
|
+
|
30
|
+
Get
|
31
|
+
|
32
|
+
Head
|
33
|
+
|
34
|
+
Post
|
35
|
+
|
36
|
+
Put
|
37
|
+
|
38
|
+
Delete
|
39
|
+
|
40
|
+
Trace
|
41
|
+
|
42
|
+
Options
|
43
|
+
|
44
|
+
Connect
|
45
|
+
|
46
|
+
Patch
|
47
|
+
"""
|
48
|
+
Connect: typing.ClassVar[Request.Method] # value = <Method.Connect: 8>
|
49
|
+
Delete: typing.ClassVar[Request.Method] # value = <Method.Delete: 5>
|
50
|
+
Get: typing.ClassVar[Request.Method] # value = <Method.Get: 1>
|
51
|
+
Head: typing.ClassVar[Request.Method] # value = <Method.Head: 2>
|
52
|
+
Options: typing.ClassVar[Request.Method] # value = <Method.Options: 7>
|
53
|
+
Patch: typing.ClassVar[Request.Method] # value = <Method.Patch: 9>
|
54
|
+
Post: typing.ClassVar[Request.Method] # value = <Method.Post: 3>
|
55
|
+
Put: typing.ClassVar[Request.Method] # value = <Method.Put: 4>
|
56
|
+
Trace: typing.ClassVar[Request.Method] # value = <Method.Trace: 6>
|
57
|
+
Undefined: typing.ClassVar[Request.Method] # value = <Method.Undefined: 0>
|
58
|
+
__members__: typing.ClassVar[dict[str, Request.Method]] # value = {'Undefined': <Method.Undefined: 0>, 'Get': <Method.Get: 1>, 'Head': <Method.Head: 2>, 'Post': <Method.Post: 3>, 'Put': <Method.Put: 4>, 'Delete': <Method.Delete: 5>, 'Trace': <Method.Trace: 6>, 'Options': <Method.Options: 7>, 'Connect': <Method.Connect: 8>, 'Patch': <Method.Patch: 9>}
|
59
|
+
@staticmethod
|
60
|
+
def _pybind11_conduit_v1_(*args, **kwargs):
|
61
|
+
...
|
62
|
+
def __eq__(self, other: typing.Any) -> bool:
|
63
|
+
...
|
64
|
+
def __getstate__(self) -> int:
|
65
|
+
...
|
66
|
+
def __hash__(self) -> int:
|
67
|
+
...
|
68
|
+
def __index__(self) -> int:
|
69
|
+
...
|
70
|
+
def __init__(self, value: int) -> None:
|
71
|
+
...
|
72
|
+
def __int__(self) -> int:
|
73
|
+
...
|
74
|
+
def __ne__(self, other: typing.Any) -> bool:
|
75
|
+
...
|
76
|
+
def __repr__(self) -> str:
|
77
|
+
...
|
78
|
+
def __setstate__(self, state: int) -> None:
|
79
|
+
...
|
80
|
+
def __str__(self) -> str:
|
81
|
+
...
|
82
|
+
@property
|
83
|
+
def name(self) -> str:
|
84
|
+
...
|
85
|
+
@property
|
86
|
+
def value(self) -> int:
|
87
|
+
...
|
88
|
+
@staticmethod
|
89
|
+
def _pybind11_conduit_v1_(*args, **kwargs):
|
90
|
+
...
|
91
|
+
@staticmethod
|
92
|
+
def get(arg0: ostk.io.URL) -> Request:
|
93
|
+
...
|
94
|
+
@staticmethod
|
95
|
+
def string_from_method(arg0: ...) -> ostk.core.type.String:
|
96
|
+
...
|
97
|
+
@staticmethod
|
98
|
+
def undefined() -> Request:
|
99
|
+
...
|
100
|
+
def __init__(self, arg0: ..., arg1: ostk.io.URL, arg2: ostk.core.type.String) -> None:
|
101
|
+
...
|
102
|
+
def __repr__(self) -> str:
|
103
|
+
...
|
104
|
+
def __str__(self) -> str:
|
105
|
+
...
|
106
|
+
def get_body(self) -> ostk.core.type.String:
|
107
|
+
...
|
108
|
+
def get_method(self) -> ...:
|
109
|
+
...
|
110
|
+
def get_url(self) -> ostk.io.URL:
|
111
|
+
...
|
112
|
+
def is_defined(self) -> bool:
|
113
|
+
...
|
114
|
+
class Response:
|
115
|
+
class StatusCode:
|
116
|
+
"""
|
117
|
+
Members:
|
118
|
+
|
119
|
+
Undefined
|
120
|
+
|
121
|
+
Continue
|
122
|
+
|
123
|
+
SwitchingProtocols
|
124
|
+
|
125
|
+
Processing
|
126
|
+
|
127
|
+
EarlyHints
|
128
|
+
|
129
|
+
Ok
|
130
|
+
|
131
|
+
Created
|
132
|
+
|
133
|
+
Accepted
|
134
|
+
|
135
|
+
NonAuthoritativeInformation
|
136
|
+
|
137
|
+
NoContent
|
138
|
+
|
139
|
+
ResetContent
|
140
|
+
|
141
|
+
PartialContent
|
142
|
+
|
143
|
+
MultiStatus
|
144
|
+
|
145
|
+
AlreadyReported
|
146
|
+
|
147
|
+
IMUsed
|
148
|
+
|
149
|
+
MultipleChoices
|
150
|
+
|
151
|
+
MovedPermanently
|
152
|
+
|
153
|
+
Found
|
154
|
+
|
155
|
+
SeeOther
|
156
|
+
|
157
|
+
NotModified
|
158
|
+
|
159
|
+
UseProxy
|
160
|
+
|
161
|
+
SwitchProxy
|
162
|
+
|
163
|
+
TemporaryRedirect
|
164
|
+
|
165
|
+
PermanentRedirect
|
166
|
+
|
167
|
+
BadRequest
|
168
|
+
|
169
|
+
Unauthorized
|
170
|
+
|
171
|
+
PaymentRequired
|
172
|
+
|
173
|
+
Forbidden
|
174
|
+
|
175
|
+
NotFound
|
176
|
+
|
177
|
+
MethodNotAllowed
|
178
|
+
|
179
|
+
NotAcceptable
|
180
|
+
|
181
|
+
ProxyAuthenticationRequired
|
182
|
+
|
183
|
+
RequestTimeout
|
184
|
+
|
185
|
+
Conflict
|
186
|
+
|
187
|
+
Gone
|
188
|
+
|
189
|
+
LengthRequired
|
190
|
+
|
191
|
+
PreconditionFailed
|
192
|
+
|
193
|
+
PayloadTooLarge
|
194
|
+
|
195
|
+
URITooLong
|
196
|
+
|
197
|
+
UnsupportedMediaType
|
198
|
+
|
199
|
+
RangeNotSatisfiable
|
200
|
+
|
201
|
+
ExpectationFailed
|
202
|
+
|
203
|
+
ImATeapot
|
204
|
+
|
205
|
+
MisdirectedRequest
|
206
|
+
|
207
|
+
UnprocessableEntity
|
208
|
+
|
209
|
+
Locked
|
210
|
+
|
211
|
+
FailedDependency
|
212
|
+
|
213
|
+
UpgradeRequired
|
214
|
+
|
215
|
+
PreconditionRequired
|
216
|
+
|
217
|
+
TooManyRequests
|
218
|
+
|
219
|
+
RequestHeaderFieldsTooLarge
|
220
|
+
|
221
|
+
UnavailableForLegalReasons
|
222
|
+
|
223
|
+
InternalServerError
|
224
|
+
|
225
|
+
NotImplemented
|
226
|
+
|
227
|
+
BadGateway
|
228
|
+
|
229
|
+
ServiceUnavailable
|
230
|
+
|
231
|
+
GatewayTimeout
|
232
|
+
|
233
|
+
HTTPVersionNotSupported
|
234
|
+
|
235
|
+
VariantAlsoNegotiates
|
236
|
+
|
237
|
+
InsufficientStorage
|
238
|
+
|
239
|
+
LoopDetected
|
240
|
+
|
241
|
+
NotExtended
|
242
|
+
|
243
|
+
NetworkAuthenticationRequire
|
244
|
+
"""
|
245
|
+
Accepted: typing.ClassVar[Response.StatusCode] # value = <StatusCode.Accepted: 202>
|
246
|
+
AlreadyReported: typing.ClassVar[Response.StatusCode] # value = <StatusCode.AlreadyReported: 208>
|
247
|
+
BadGateway: typing.ClassVar[Response.StatusCode] # value = <StatusCode.BadGateway: 502>
|
248
|
+
BadRequest: typing.ClassVar[Response.StatusCode] # value = <StatusCode.BadRequest: 400>
|
249
|
+
Conflict: typing.ClassVar[Response.StatusCode] # value = <StatusCode.Conflict: 409>
|
250
|
+
Continue: typing.ClassVar[Response.StatusCode] # value = <StatusCode.Continue: 100>
|
251
|
+
Created: typing.ClassVar[Response.StatusCode] # value = <StatusCode.Created: 201>
|
252
|
+
EarlyHints: typing.ClassVar[Response.StatusCode] # value = <StatusCode.EarlyHints: 103>
|
253
|
+
ExpectationFailed: typing.ClassVar[Response.StatusCode] # value = <StatusCode.ExpectationFailed: 417>
|
254
|
+
FailedDependency: typing.ClassVar[Response.StatusCode] # value = <StatusCode.FailedDependency: 424>
|
255
|
+
Forbidden: typing.ClassVar[Response.StatusCode] # value = <StatusCode.Forbidden: 403>
|
256
|
+
Found: typing.ClassVar[Response.StatusCode] # value = <StatusCode.Found: 302>
|
257
|
+
GatewayTimeout: typing.ClassVar[Response.StatusCode] # value = <StatusCode.GatewayTimeout: 504>
|
258
|
+
Gone: typing.ClassVar[Response.StatusCode] # value = <StatusCode.Gone: 410>
|
259
|
+
HTTPVersionNotSupported: typing.ClassVar[Response.StatusCode] # value = <StatusCode.HTTPVersionNotSupported: 505>
|
260
|
+
IMUsed: typing.ClassVar[Response.StatusCode] # value = <StatusCode.IMUsed: 226>
|
261
|
+
ImATeapot: typing.ClassVar[Response.StatusCode] # value = <StatusCode.ImATeapot: 418>
|
262
|
+
InsufficientStorage: typing.ClassVar[Response.StatusCode] # value = <StatusCode.InsufficientStorage: 507>
|
263
|
+
InternalServerError: typing.ClassVar[Response.StatusCode] # value = <StatusCode.InternalServerError: 500>
|
264
|
+
LengthRequired: typing.ClassVar[Response.StatusCode] # value = <StatusCode.LengthRequired: 411>
|
265
|
+
Locked: typing.ClassVar[Response.StatusCode] # value = <StatusCode.Locked: 423>
|
266
|
+
LoopDetected: typing.ClassVar[Response.StatusCode] # value = <StatusCode.LoopDetected: 508>
|
267
|
+
MethodNotAllowed: typing.ClassVar[Response.StatusCode] # value = <StatusCode.MethodNotAllowed: 405>
|
268
|
+
MisdirectedRequest: typing.ClassVar[Response.StatusCode] # value = <StatusCode.MisdirectedRequest: 421>
|
269
|
+
MovedPermanently: typing.ClassVar[Response.StatusCode] # value = <StatusCode.MovedPermanently: 301>
|
270
|
+
MultiStatus: typing.ClassVar[Response.StatusCode] # value = <StatusCode.MultiStatus: 207>
|
271
|
+
MultipleChoices: typing.ClassVar[Response.StatusCode] # value = <StatusCode.MultipleChoices: 300>
|
272
|
+
NetworkAuthenticationRequire: typing.ClassVar[Response.StatusCode] # value = <StatusCode.NetworkAuthenticationRequire: 511>
|
273
|
+
NoContent: typing.ClassVar[Response.StatusCode] # value = <StatusCode.NoContent: 204>
|
274
|
+
NonAuthoritativeInformation: typing.ClassVar[Response.StatusCode] # value = <StatusCode.NonAuthoritativeInformation: 203>
|
275
|
+
NotAcceptable: typing.ClassVar[Response.StatusCode] # value = <StatusCode.NotAcceptable: 406>
|
276
|
+
NotExtended: typing.ClassVar[Response.StatusCode] # value = <StatusCode.NotExtended: 510>
|
277
|
+
NotFound: typing.ClassVar[Response.StatusCode] # value = <StatusCode.NotFound: 404>
|
278
|
+
NotImplemented: typing.ClassVar[Response.StatusCode] # value = <StatusCode.NotImplemented: 501>
|
279
|
+
NotModified: typing.ClassVar[Response.StatusCode] # value = <StatusCode.NotModified: 304>
|
280
|
+
Ok: typing.ClassVar[Response.StatusCode] # value = <StatusCode.Ok: 200>
|
281
|
+
PartialContent: typing.ClassVar[Response.StatusCode] # value = <StatusCode.PartialContent: 206>
|
282
|
+
PayloadTooLarge: typing.ClassVar[Response.StatusCode] # value = <StatusCode.PayloadTooLarge: 413>
|
283
|
+
PaymentRequired: typing.ClassVar[Response.StatusCode] # value = <StatusCode.PaymentRequired: 402>
|
284
|
+
PermanentRedirect: typing.ClassVar[Response.StatusCode] # value = <StatusCode.PermanentRedirect: 308>
|
285
|
+
PreconditionFailed: typing.ClassVar[Response.StatusCode] # value = <StatusCode.PreconditionFailed: 412>
|
286
|
+
PreconditionRequired: typing.ClassVar[Response.StatusCode] # value = <StatusCode.PreconditionRequired: 428>
|
287
|
+
Processing: typing.ClassVar[Response.StatusCode] # value = <StatusCode.Processing: 102>
|
288
|
+
ProxyAuthenticationRequired: typing.ClassVar[Response.StatusCode] # value = <StatusCode.ProxyAuthenticationRequired: 407>
|
289
|
+
RangeNotSatisfiable: typing.ClassVar[Response.StatusCode] # value = <StatusCode.RangeNotSatisfiable: 416>
|
290
|
+
RequestHeaderFieldsTooLarge: typing.ClassVar[Response.StatusCode] # value = <StatusCode.RequestHeaderFieldsTooLarge: 431>
|
291
|
+
RequestTimeout: typing.ClassVar[Response.StatusCode] # value = <StatusCode.RequestTimeout: 408>
|
292
|
+
ResetContent: typing.ClassVar[Response.StatusCode] # value = <StatusCode.ResetContent: 205>
|
293
|
+
SeeOther: typing.ClassVar[Response.StatusCode] # value = <StatusCode.SeeOther: 303>
|
294
|
+
ServiceUnavailable: typing.ClassVar[Response.StatusCode] # value = <StatusCode.ServiceUnavailable: 503>
|
295
|
+
SwitchProxy: typing.ClassVar[Response.StatusCode] # value = <StatusCode.SwitchProxy: 306>
|
296
|
+
SwitchingProtocols: typing.ClassVar[Response.StatusCode] # value = <StatusCode.SwitchingProtocols: 101>
|
297
|
+
TemporaryRedirect: typing.ClassVar[Response.StatusCode] # value = <StatusCode.TemporaryRedirect: 307>
|
298
|
+
TooManyRequests: typing.ClassVar[Response.StatusCode] # value = <StatusCode.TooManyRequests: 429>
|
299
|
+
URITooLong: typing.ClassVar[Response.StatusCode] # value = <StatusCode.URITooLong: 414>
|
300
|
+
Unauthorized: typing.ClassVar[Response.StatusCode] # value = <StatusCode.Unauthorized: 401>
|
301
|
+
UnavailableForLegalReasons: typing.ClassVar[Response.StatusCode] # value = <StatusCode.UnavailableForLegalReasons: 451>
|
302
|
+
Undefined: typing.ClassVar[Response.StatusCode] # value = <StatusCode.Undefined: 0>
|
303
|
+
UnprocessableEntity: typing.ClassVar[Response.StatusCode] # value = <StatusCode.UnprocessableEntity: 422>
|
304
|
+
UnsupportedMediaType: typing.ClassVar[Response.StatusCode] # value = <StatusCode.UnsupportedMediaType: 415>
|
305
|
+
UpgradeRequired: typing.ClassVar[Response.StatusCode] # value = <StatusCode.UpgradeRequired: 426>
|
306
|
+
UseProxy: typing.ClassVar[Response.StatusCode] # value = <StatusCode.UseProxy: 305>
|
307
|
+
VariantAlsoNegotiates: typing.ClassVar[Response.StatusCode] # value = <StatusCode.VariantAlsoNegotiates: 506>
|
308
|
+
__members__: typing.ClassVar[dict[str, Response.StatusCode]] # value = {'Undefined': <StatusCode.Undefined: 0>, 'Continue': <StatusCode.Continue: 100>, 'SwitchingProtocols': <StatusCode.SwitchingProtocols: 101>, 'Processing': <StatusCode.Processing: 102>, 'EarlyHints': <StatusCode.EarlyHints: 103>, 'Ok': <StatusCode.Ok: 200>, 'Created': <StatusCode.Created: 201>, 'Accepted': <StatusCode.Accepted: 202>, 'NonAuthoritativeInformation': <StatusCode.NonAuthoritativeInformation: 203>, 'NoContent': <StatusCode.NoContent: 204>, 'ResetContent': <StatusCode.ResetContent: 205>, 'PartialContent': <StatusCode.PartialContent: 206>, 'MultiStatus': <StatusCode.MultiStatus: 207>, 'AlreadyReported': <StatusCode.AlreadyReported: 208>, 'IMUsed': <StatusCode.IMUsed: 226>, 'MultipleChoices': <StatusCode.MultipleChoices: 300>, 'MovedPermanently': <StatusCode.MovedPermanently: 301>, 'Found': <StatusCode.Found: 302>, 'SeeOther': <StatusCode.SeeOther: 303>, 'NotModified': <StatusCode.NotModified: 304>, 'UseProxy': <StatusCode.UseProxy: 305>, 'SwitchProxy': <StatusCode.SwitchProxy: 306>, 'TemporaryRedirect': <StatusCode.TemporaryRedirect: 307>, 'PermanentRedirect': <StatusCode.PermanentRedirect: 308>, 'BadRequest': <StatusCode.BadRequest: 400>, 'Unauthorized': <StatusCode.Unauthorized: 401>, 'PaymentRequired': <StatusCode.PaymentRequired: 402>, 'Forbidden': <StatusCode.Forbidden: 403>, 'NotFound': <StatusCode.NotFound: 404>, 'MethodNotAllowed': <StatusCode.MethodNotAllowed: 405>, 'NotAcceptable': <StatusCode.NotAcceptable: 406>, 'ProxyAuthenticationRequired': <StatusCode.ProxyAuthenticationRequired: 407>, 'RequestTimeout': <StatusCode.RequestTimeout: 408>, 'Conflict': <StatusCode.Conflict: 409>, 'Gone': <StatusCode.Gone: 410>, 'LengthRequired': <StatusCode.LengthRequired: 411>, 'PreconditionFailed': <StatusCode.PreconditionFailed: 412>, 'PayloadTooLarge': <StatusCode.PayloadTooLarge: 413>, 'URITooLong': <StatusCode.URITooLong: 414>, 'UnsupportedMediaType': <StatusCode.UnsupportedMediaType: 415>, 'RangeNotSatisfiable': <StatusCode.RangeNotSatisfiable: 416>, 'ExpectationFailed': <StatusCode.ExpectationFailed: 417>, 'ImATeapot': <StatusCode.ImATeapot: 418>, 'MisdirectedRequest': <StatusCode.MisdirectedRequest: 421>, 'UnprocessableEntity': <StatusCode.UnprocessableEntity: 422>, 'Locked': <StatusCode.Locked: 423>, 'FailedDependency': <StatusCode.FailedDependency: 424>, 'UpgradeRequired': <StatusCode.UpgradeRequired: 426>, 'PreconditionRequired': <StatusCode.PreconditionRequired: 428>, 'TooManyRequests': <StatusCode.TooManyRequests: 429>, 'RequestHeaderFieldsTooLarge': <StatusCode.RequestHeaderFieldsTooLarge: 431>, 'UnavailableForLegalReasons': <StatusCode.UnavailableForLegalReasons: 451>, 'InternalServerError': <StatusCode.InternalServerError: 500>, 'NotImplemented': <StatusCode.NotImplemented: 501>, 'BadGateway': <StatusCode.BadGateway: 502>, 'ServiceUnavailable': <StatusCode.ServiceUnavailable: 503>, 'GatewayTimeout': <StatusCode.GatewayTimeout: 504>, 'HTTPVersionNotSupported': <StatusCode.HTTPVersionNotSupported: 505>, 'VariantAlsoNegotiates': <StatusCode.VariantAlsoNegotiates: 506>, 'InsufficientStorage': <StatusCode.InsufficientStorage: 507>, 'LoopDetected': <StatusCode.LoopDetected: 508>, 'NotExtended': <StatusCode.NotExtended: 510>, 'NetworkAuthenticationRequire': <StatusCode.NetworkAuthenticationRequire: 511>}
|
309
|
+
@staticmethod
|
310
|
+
def _pybind11_conduit_v1_(*args, **kwargs):
|
311
|
+
...
|
312
|
+
def __eq__(self, other: typing.Any) -> bool:
|
313
|
+
...
|
314
|
+
def __getstate__(self) -> int:
|
315
|
+
...
|
316
|
+
def __hash__(self) -> int:
|
317
|
+
...
|
318
|
+
def __index__(self) -> int:
|
319
|
+
...
|
320
|
+
def __init__(self, value: int) -> None:
|
321
|
+
...
|
322
|
+
def __int__(self) -> int:
|
323
|
+
...
|
324
|
+
def __ne__(self, other: typing.Any) -> bool:
|
325
|
+
...
|
326
|
+
def __repr__(self) -> str:
|
327
|
+
...
|
328
|
+
def __setstate__(self, state: int) -> None:
|
329
|
+
...
|
330
|
+
def __str__(self) -> str:
|
331
|
+
...
|
332
|
+
@property
|
333
|
+
def name(self) -> str:
|
334
|
+
...
|
335
|
+
@property
|
336
|
+
def value(self) -> int:
|
337
|
+
...
|
338
|
+
@staticmethod
|
339
|
+
def _pybind11_conduit_v1_(*args, **kwargs):
|
340
|
+
...
|
341
|
+
@staticmethod
|
342
|
+
def string_from_status_code(arg0: ...) -> ostk.core.type.String:
|
343
|
+
...
|
344
|
+
@staticmethod
|
345
|
+
def undefined() -> Response:
|
346
|
+
...
|
347
|
+
def __init__(self, arg0: ..., arg1: ostk.core.type.String) -> None:
|
348
|
+
...
|
349
|
+
def __repr__(self) -> str:
|
350
|
+
...
|
351
|
+
def __str__(self) -> str:
|
352
|
+
...
|
353
|
+
def get_body(self) -> ostk.core.type.String:
|
354
|
+
...
|
355
|
+
def get_status_code(self) -> ...:
|
356
|
+
...
|
357
|
+
def is_defined(self) -> bool:
|
358
|
+
...
|
359
|
+
def is_ok(self) -> bool:
|
360
|
+
...
|
Binary file
|
ostk/io/py.typed
ADDED
File without changes
|
ostk/io/test/__init__.py
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Apache License 2.0
|
@@ -0,0 +1 @@
|
|
1
|
+
# Apache License 2.0
|
@@ -0,0 +1 @@
|
|
1
|
+
# Apache License 2.0
|
@@ -0,0 +1 @@
|
|
1
|
+
# Apache License 2.0
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# Apache License 2.0
|
2
|
+
|
3
|
+
import pytest
|
4
|
+
|
5
|
+
import ostk.io as io
|
6
|
+
from ostk.core.filesystem import Directory, File, Path
|
7
|
+
|
8
|
+
URL = io.URL
|
9
|
+
Request = io.ip.tcp.http.Request
|
10
|
+
Response = io.ip.tcp.http.Response
|
11
|
+
Client = io.ip.tcp.http.Client
|
12
|
+
|
13
|
+
|
14
|
+
def test_http_client_get_success():
|
15
|
+
url = URL.parse("https://www.google.com")
|
16
|
+
|
17
|
+
response = Client.get(url)
|
18
|
+
|
19
|
+
assert response is not None
|
20
|
+
assert response.is_defined() is True
|
21
|
+
assert response.is_ok() is True
|
22
|
+
assert response.get_status_code() == Response.StatusCode.Ok
|
23
|
+
|
24
|
+
|
25
|
+
def test_http_client_send_success():
|
26
|
+
url = URL.parse("https://www.google.com")
|
27
|
+
|
28
|
+
request = Request(Request.Method.Get, url, "")
|
29
|
+
response = Client.send(request)
|
30
|
+
|
31
|
+
assert response is not None
|
32
|
+
assert response.is_defined() is True
|
33
|
+
assert response.is_ok() is True
|
34
|
+
assert response.get_status_code() == Response.StatusCode.Ok
|
35
|
+
|
36
|
+
|
37
|
+
def test_http_client_fetch_success():
|
38
|
+
url = URL.parse(
|
39
|
+
"https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png"
|
40
|
+
)
|
41
|
+
directory = Directory.path(Path.parse("/tmp"))
|
42
|
+
|
43
|
+
file_response = Client.fetch(url, directory)
|
44
|
+
|
45
|
+
assert file_response is not None
|
46
|
+
assert file_response.exists() is True
|
47
|
+
|
48
|
+
|
49
|
+
# def test_http_client_list_success():
|
50
|
+
|
51
|
+
# Disabling similar to the C++ test. The list takes about 1 minute to complete for some reason.
|
52
|
+
|
53
|
+
# url = URL.parse("ftp://naif.jpl.nasa.gov/pub/naif/generic_kernels/")
|
54
|
+
# file_input = File.path(Path.parse("/tmp/listing.txt"))
|
55
|
+
# response = Client.list(url, file_input, 3)
|
56
|
+
|
57
|
+
# assert response is not None
|
58
|
+
# assert response.is_defined() is True
|
59
|
+
# assert response.is_ok() is True
|
60
|
+
# assert response.get_status_code() == Response.StatusCode.Ok
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# Apache License 2.0
|
2
|
+
|
3
|
+
import pytest
|
4
|
+
|
5
|
+
import ostk.io as io
|
6
|
+
|
7
|
+
URL = io.URL
|
8
|
+
Request = io.ip.tcp.http.Request
|
9
|
+
Method = Request.Method
|
10
|
+
|
11
|
+
|
12
|
+
def test_http_request():
|
13
|
+
enum_members = Request.Method.__members__
|
14
|
+
|
15
|
+
list_keys = [
|
16
|
+
"Undefined",
|
17
|
+
"Get",
|
18
|
+
"Head",
|
19
|
+
"Post",
|
20
|
+
"Put",
|
21
|
+
"Delete",
|
22
|
+
"Trace",
|
23
|
+
"Options",
|
24
|
+
"Connect",
|
25
|
+
"Patch",
|
26
|
+
]
|
27
|
+
|
28
|
+
list_values = [
|
29
|
+
Method.Undefined,
|
30
|
+
Method.Get,
|
31
|
+
Method.Head,
|
32
|
+
Method.Post,
|
33
|
+
Method.Put,
|
34
|
+
Method.Delete,
|
35
|
+
Method.Trace,
|
36
|
+
Method.Options,
|
37
|
+
Method.Connect,
|
38
|
+
Method.Patch,
|
39
|
+
]
|
40
|
+
|
41
|
+
assert list(enum_members.keys()) == list_keys
|
42
|
+
assert list(enum_members.values()) == list_values
|
43
|
+
|
44
|
+
requests = []
|
45
|
+
url = URL.parse("https://www.google.com")
|
46
|
+
|
47
|
+
for request_method in list_values:
|
48
|
+
request = Request(request_method, url, "body")
|
49
|
+
assert isinstance(request, Request)
|
50
|
+
requests.append(request)
|
51
|
+
|
52
|
+
undef_request = requests[0]
|
53
|
+
get_request = requests[1]
|
54
|
+
post_request = requests[3]
|
55
|
+
|
56
|
+
assert undef_request.is_defined() is False
|
57
|
+
assert Request.undefined().is_defined() is False
|
58
|
+
assert get_request.is_defined()
|
59
|
+
assert post_request.is_defined()
|
60
|
+
|
61
|
+
converted_methods = []
|
62
|
+
for method_value in list_values:
|
63
|
+
converted_methods.append(Request.string_from_method(method_value))
|
64
|
+
assert converted_methods == list_keys
|
65
|
+
|
66
|
+
assert get_request.get_method() == Method.Get
|
67
|
+
assert post_request.get_method() == Method.Post
|
68
|
+
|
69
|
+
with pytest.raises(RuntimeError):
|
70
|
+
undef_request.get_method()
|
71
|
+
|
72
|
+
assert get_request.get_url() == url
|
73
|
+
assert post_request.get_url() == url
|
74
|
+
|
75
|
+
with pytest.raises(RuntimeError):
|
76
|
+
undef_request.get_url()
|
77
|
+
|
78
|
+
assert get_request.get_body() == "body"
|
79
|
+
assert post_request.get_body() == "body"
|
80
|
+
|
81
|
+
with pytest.raises(RuntimeError):
|
82
|
+
undef_request.get_body()
|
83
|
+
|
84
|
+
new_get_request = Request.get(url)
|
85
|
+
|
86
|
+
assert isinstance(new_get_request, Request)
|
87
|
+
assert new_get_request.is_defined()
|
88
|
+
assert new_get_request.get_method() == Method.Get
|
89
|
+
assert new_get_request.get_url() == url
|
90
|
+
assert new_get_request.get_body() == ""
|
@@ -0,0 +1,198 @@
|
|
1
|
+
# Apache License 2.0
|
2
|
+
|
3
|
+
import pytest
|
4
|
+
|
5
|
+
import ostk.io as io
|
6
|
+
|
7
|
+
URL = io.URL
|
8
|
+
Response = io.ip.tcp.http.Response
|
9
|
+
StatusCode = Response.StatusCode
|
10
|
+
|
11
|
+
|
12
|
+
def test_http_response():
|
13
|
+
enum_members = Response.StatusCode.__members__
|
14
|
+
|
15
|
+
list_keys = [
|
16
|
+
"Undefined",
|
17
|
+
"Continue",
|
18
|
+
"SwitchingProtocols",
|
19
|
+
"Processing",
|
20
|
+
"EarlyHints",
|
21
|
+
"Ok",
|
22
|
+
"Created",
|
23
|
+
"Accepted",
|
24
|
+
"NonAuthoritativeInformation",
|
25
|
+
"NoContent",
|
26
|
+
"ResetContent",
|
27
|
+
"PartialContent",
|
28
|
+
"MultiStatus",
|
29
|
+
"AlreadyReported",
|
30
|
+
"IMUsed",
|
31
|
+
"MultipleChoices",
|
32
|
+
"MovedPermanently",
|
33
|
+
"Found",
|
34
|
+
"SeeOther",
|
35
|
+
"NotModified",
|
36
|
+
"UseProxy",
|
37
|
+
"SwitchProxy",
|
38
|
+
"TemporaryRedirect",
|
39
|
+
"PermanentRedirect",
|
40
|
+
"BadRequest",
|
41
|
+
"Unauthorized",
|
42
|
+
"PaymentRequired",
|
43
|
+
"Forbidden",
|
44
|
+
"NotFound",
|
45
|
+
"MethodNotAllowed",
|
46
|
+
"NotAcceptable",
|
47
|
+
"ProxyAuthenticationRequired",
|
48
|
+
"RequestTimeout",
|
49
|
+
"Conflict",
|
50
|
+
"Gone",
|
51
|
+
"LengthRequired",
|
52
|
+
"PreconditionFailed",
|
53
|
+
"PayloadTooLarge",
|
54
|
+
"URITooLong",
|
55
|
+
"UnsupportedMediaType",
|
56
|
+
"RangeNotSatisfiable",
|
57
|
+
"ExpectationFailed",
|
58
|
+
"ImATeapot",
|
59
|
+
"MisdirectedRequest",
|
60
|
+
"UnprocessableEntity",
|
61
|
+
"Locked",
|
62
|
+
"FailedDependency",
|
63
|
+
"UpgradeRequired",
|
64
|
+
"PreconditionRequired",
|
65
|
+
"TooManyRequests",
|
66
|
+
"RequestHeaderFieldsTooLarge",
|
67
|
+
"UnavailableForLegalReasons",
|
68
|
+
"InternalServerError",
|
69
|
+
"NotImplemented",
|
70
|
+
"BadGateway",
|
71
|
+
"ServiceUnavailable",
|
72
|
+
"GatewayTimeout",
|
73
|
+
"HTTPVersionNotSupported",
|
74
|
+
"VariantAlsoNegotiates",
|
75
|
+
"InsufficientStorage",
|
76
|
+
"LoopDetected",
|
77
|
+
"NotExtended",
|
78
|
+
"NetworkAuthenticationRequire",
|
79
|
+
]
|
80
|
+
|
81
|
+
list_values = [
|
82
|
+
StatusCode.Undefined,
|
83
|
+
StatusCode.Continue,
|
84
|
+
StatusCode.SwitchingProtocols,
|
85
|
+
StatusCode.Processing,
|
86
|
+
StatusCode.EarlyHints,
|
87
|
+
StatusCode.Ok,
|
88
|
+
StatusCode.Created,
|
89
|
+
StatusCode.Accepted,
|
90
|
+
StatusCode.NonAuthoritativeInformation,
|
91
|
+
StatusCode.NoContent,
|
92
|
+
StatusCode.ResetContent,
|
93
|
+
StatusCode.PartialContent,
|
94
|
+
StatusCode.MultiStatus,
|
95
|
+
StatusCode.AlreadyReported,
|
96
|
+
StatusCode.IMUsed,
|
97
|
+
StatusCode.MultipleChoices,
|
98
|
+
StatusCode.MovedPermanently,
|
99
|
+
StatusCode.Found,
|
100
|
+
StatusCode.SeeOther,
|
101
|
+
StatusCode.NotModified,
|
102
|
+
StatusCode.UseProxy,
|
103
|
+
StatusCode.SwitchProxy,
|
104
|
+
StatusCode.TemporaryRedirect,
|
105
|
+
StatusCode.PermanentRedirect,
|
106
|
+
StatusCode.BadRequest,
|
107
|
+
StatusCode.Unauthorized,
|
108
|
+
StatusCode.PaymentRequired,
|
109
|
+
StatusCode.Forbidden,
|
110
|
+
StatusCode.NotFound,
|
111
|
+
StatusCode.MethodNotAllowed,
|
112
|
+
StatusCode.NotAcceptable,
|
113
|
+
StatusCode.ProxyAuthenticationRequired,
|
114
|
+
StatusCode.RequestTimeout,
|
115
|
+
StatusCode.Conflict,
|
116
|
+
StatusCode.Gone,
|
117
|
+
StatusCode.LengthRequired,
|
118
|
+
StatusCode.PreconditionFailed,
|
119
|
+
StatusCode.PayloadTooLarge,
|
120
|
+
StatusCode.URITooLong,
|
121
|
+
StatusCode.UnsupportedMediaType,
|
122
|
+
StatusCode.RangeNotSatisfiable,
|
123
|
+
StatusCode.ExpectationFailed,
|
124
|
+
StatusCode.ImATeapot,
|
125
|
+
StatusCode.MisdirectedRequest,
|
126
|
+
StatusCode.UnprocessableEntity,
|
127
|
+
StatusCode.Locked,
|
128
|
+
StatusCode.FailedDependency,
|
129
|
+
StatusCode.UpgradeRequired,
|
130
|
+
StatusCode.PreconditionRequired,
|
131
|
+
StatusCode.TooManyRequests,
|
132
|
+
StatusCode.RequestHeaderFieldsTooLarge,
|
133
|
+
StatusCode.UnavailableForLegalReasons,
|
134
|
+
StatusCode.InternalServerError,
|
135
|
+
StatusCode.NotImplemented,
|
136
|
+
StatusCode.BadGateway,
|
137
|
+
StatusCode.ServiceUnavailable,
|
138
|
+
StatusCode.GatewayTimeout,
|
139
|
+
StatusCode.HTTPVersionNotSupported,
|
140
|
+
StatusCode.VariantAlsoNegotiates,
|
141
|
+
StatusCode.InsufficientStorage,
|
142
|
+
StatusCode.LoopDetected,
|
143
|
+
StatusCode.NotExtended,
|
144
|
+
StatusCode.NetworkAuthenticationRequire,
|
145
|
+
]
|
146
|
+
|
147
|
+
assert list(enum_members.keys()) == list_keys
|
148
|
+
assert list(enum_members.values()) == list_values
|
149
|
+
|
150
|
+
responses = []
|
151
|
+
for i in range(len(list_values)):
|
152
|
+
statuscode = list_values[i]
|
153
|
+
response = Response(statuscode, f"body{i}")
|
154
|
+
assert isinstance(response, Response)
|
155
|
+
if i > 0:
|
156
|
+
assert response.is_defined()
|
157
|
+
responses.append(response)
|
158
|
+
|
159
|
+
assert Response.string_from_status_code(statuscode) == list_keys[i]
|
160
|
+
|
161
|
+
response_0 = responses[0]
|
162
|
+
response_2 = responses[2]
|
163
|
+
response_3 = responses[3]
|
164
|
+
response_4 = responses[4]
|
165
|
+
response_5 = responses[5]
|
166
|
+
|
167
|
+
assert response_0.is_defined() is False
|
168
|
+
assert response_2.is_defined() is True
|
169
|
+
assert response_3.is_defined() is True
|
170
|
+
assert response_4.is_defined() is True
|
171
|
+
assert isinstance(Response.undefined(), Response)
|
172
|
+
assert Response.undefined().is_defined() is False
|
173
|
+
|
174
|
+
with pytest.raises(RuntimeError):
|
175
|
+
response_0.get_body()
|
176
|
+
|
177
|
+
assert response_2.get_body() == "body2"
|
178
|
+
assert response_3.get_body() == "body3"
|
179
|
+
assert response_4.get_body() == "body4"
|
180
|
+
|
181
|
+
with pytest.raises(RuntimeError):
|
182
|
+
response_0.is_ok()
|
183
|
+
|
184
|
+
assert response_2.is_ok() is False
|
185
|
+
assert response_3.is_ok() is False
|
186
|
+
assert response_4.is_ok() is False
|
187
|
+
|
188
|
+
with pytest.raises(RuntimeError):
|
189
|
+
response_0.get_status_code()
|
190
|
+
|
191
|
+
assert response_2.get_status_code() == StatusCode.SwitchingProtocols
|
192
|
+
assert response_3.get_status_code() == StatusCode.Processing
|
193
|
+
assert response_4.get_status_code() == StatusCode.EarlyHints
|
194
|
+
|
195
|
+
assert response_5.is_defined() is True
|
196
|
+
assert response_5.is_ok() is True
|
197
|
+
assert response_5.get_status_code() == StatusCode.Ok
|
198
|
+
assert response_5.get_body() == "body5"
|
@@ -0,0 +1 @@
|
|
1
|
+
# Apache License 2.0
|
@@ -0,0 +1,157 @@
|
|
1
|
+
# Apache License 2.0
|
2
|
+
|
3
|
+
import pytest
|
4
|
+
|
5
|
+
import ostk.io as io
|
6
|
+
|
7
|
+
from ostk.core.type import String
|
8
|
+
|
9
|
+
URL = io.URL
|
10
|
+
|
11
|
+
|
12
|
+
def test_url_constructors():
|
13
|
+
# default constructor
|
14
|
+
scheme = "https"
|
15
|
+
host = "domain.org"
|
16
|
+
path = "/path/to/page"
|
17
|
+
port = 443
|
18
|
+
user = "user"
|
19
|
+
password = "password"
|
20
|
+
query = URL.Query.undefined()
|
21
|
+
fragment = "fragment"
|
22
|
+
url = URL(scheme, host, path, port, user, password, query, fragment)
|
23
|
+
assert isinstance(url, URL)
|
24
|
+
|
25
|
+
# undefined url constructor
|
26
|
+
url = URL.undefined()
|
27
|
+
assert isinstance(url, URL)
|
28
|
+
|
29
|
+
# parsing url constructor
|
30
|
+
url = URL.parse("https://www.google.com")
|
31
|
+
assert isinstance(url, URL)
|
32
|
+
|
33
|
+
|
34
|
+
def test_url_getter_functions():
|
35
|
+
scheme = "https"
|
36
|
+
host = "domain.org"
|
37
|
+
path = "/path/to/page"
|
38
|
+
port = 443
|
39
|
+
user = "user"
|
40
|
+
password = "password"
|
41
|
+
query = URL.Query.undefined()
|
42
|
+
fragment = "fragment"
|
43
|
+
url = URL(scheme, host, path, port, user, password, query, fragment)
|
44
|
+
|
45
|
+
assert url.get_scheme() == scheme
|
46
|
+
assert url.get_host() == host
|
47
|
+
assert url.get_path() == path
|
48
|
+
assert url.get_port() == port
|
49
|
+
assert url.get_user() == user
|
50
|
+
assert url.get_password() == password
|
51
|
+
assert url.get_query() == query
|
52
|
+
assert url.get_fragment() == fragment
|
53
|
+
|
54
|
+
|
55
|
+
def test_url_setter_functions():
|
56
|
+
url = URL.parse("https://www.google.com")
|
57
|
+
|
58
|
+
url.set_scheme("http")
|
59
|
+
url.set_host("youtube.com")
|
60
|
+
url.set_path("/path/to/page")
|
61
|
+
url.set_port(443)
|
62
|
+
url.set_user("Bob")
|
63
|
+
url.set_password("Sponge")
|
64
|
+
url.set_query(URL.Query.undefined())
|
65
|
+
url.set_fragment("frag")
|
66
|
+
|
67
|
+
assert url.get_scheme() == "http"
|
68
|
+
assert url.get_host() == "youtube.com"
|
69
|
+
assert url.get_path() == "/path/to/page"
|
70
|
+
assert url.get_port() == 443
|
71
|
+
assert url.get_user() == "Bob"
|
72
|
+
assert url.get_password() == "Sponge"
|
73
|
+
assert url.get_query().is_defined() is False
|
74
|
+
assert url.get_fragment() == "frag"
|
75
|
+
|
76
|
+
|
77
|
+
def test_url_comparators():
|
78
|
+
url_1 = URL.parse("https://www.google.com")
|
79
|
+
url_2 = URL.parse("https://www.youtube.com")
|
80
|
+
|
81
|
+
assert url_1 == url_1
|
82
|
+
assert url_1 != url_2
|
83
|
+
|
84
|
+
|
85
|
+
def test_url_to_string():
|
86
|
+
url = URL.parse("https://www.google.com")
|
87
|
+
|
88
|
+
assert isinstance(url.to_string(), String)
|
89
|
+
assert url.to_string() == "https://www.google.com"
|
90
|
+
assert url.to_string(False) == url.to_string()
|
91
|
+
# assert url.to_string(True) == 'https://%20www.google.com'
|
92
|
+
|
93
|
+
|
94
|
+
def test_url_operators():
|
95
|
+
url_1 = URL.parse("https://www.google.com")
|
96
|
+
url_2 = url_1 + "/stuff"
|
97
|
+
|
98
|
+
assert url_2.to_string() == "https://www.google.com/stuff"
|
99
|
+
assert isinstance(url_2, URL)
|
100
|
+
|
101
|
+
|
102
|
+
def test_url_query():
|
103
|
+
parameter_1 = URL.Query.Parameter("name1", "value1")
|
104
|
+
parameter_2 = URL.Query.Parameter("name2", "value2")
|
105
|
+
|
106
|
+
list_parameters = [parameter_1, parameter_2, parameter_1, parameter_2]
|
107
|
+
tuple_parameters = (parameter_1, parameter_2)
|
108
|
+
|
109
|
+
assert parameter_1 == parameter_1
|
110
|
+
assert parameter_1 != parameter_2
|
111
|
+
assert parameter_1.is_defined()
|
112
|
+
assert parameter_2.is_defined()
|
113
|
+
|
114
|
+
assert parameter_1.get_name() == "name1"
|
115
|
+
assert parameter_1.get_value() == "value1"
|
116
|
+
|
117
|
+
assert parameter_2.get_name() == "name2"
|
118
|
+
assert parameter_2.get_value() == "value2"
|
119
|
+
|
120
|
+
query_1 = URL.Query(list_parameters)
|
121
|
+
query_2 = URL.Query(tuple_parameters)
|
122
|
+
query_3 = URL.Query((parameter_1,))
|
123
|
+
|
124
|
+
assert isinstance(query_1, URL.Query)
|
125
|
+
assert isinstance(query_2, URL.Query)
|
126
|
+
assert isinstance(query_3, URL.Query)
|
127
|
+
|
128
|
+
assert query_1.is_defined()
|
129
|
+
assert query_2.is_defined()
|
130
|
+
assert query_3.is_defined()
|
131
|
+
assert URL.Query.undefined().is_defined() is False
|
132
|
+
|
133
|
+
assert query_1.has_parameter_with_name("name1")
|
134
|
+
assert query_1.has_parameter_with_name("name2")
|
135
|
+
assert query_2.has_parameter_with_name("name1")
|
136
|
+
assert query_2.has_parameter_with_name("name2")
|
137
|
+
assert query_3.has_parameter_with_name("name1") is True
|
138
|
+
assert query_3.has_parameter_with_name("name2") is False
|
139
|
+
|
140
|
+
assert query_1.to_string() == "name1=value1&name2=value2&name1=value1&name2=value2"
|
141
|
+
assert query_2.to_string() == "name1=value1&name2=value2"
|
142
|
+
assert query_3.to_string() == "name1=value1"
|
143
|
+
|
144
|
+
query_3.add_parameter(parameter_2)
|
145
|
+
assert query_3.to_string() == "name1=value1&name2=value2"
|
146
|
+
|
147
|
+
assert query_3 == query_2
|
148
|
+
assert query_3 != query_1
|
149
|
+
assert query_2 != query_1
|
150
|
+
|
151
|
+
param_1 = query_1.get_parameter_with_name("name1")
|
152
|
+
param_2 = query_2.get_parameter_with_name("name2")
|
153
|
+
|
154
|
+
assert isinstance(param_1, String)
|
155
|
+
assert isinstance(param_2, String)
|
156
|
+
assert param_1 == "value1"
|
157
|
+
assert param_2 == "value2"
|