open-space-toolkit-io 3.0.1__py311-none-manylinux2014_x86_64.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,27 @@
1
+ Metadata-Version: 2.1
2
+ Name: open-space-toolkit-io
3
+ Version: 3.0.1
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 ~=3.0.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,18 @@
1
+ ostk/__init__.py,sha256=epnVn2PwdQkUDZ1msqBRO5nEZIOUBIq-IfK3IlNPijE,21
2
+ ostk/io/OpenSpaceToolkitIOPy.cpython-311-x86_64-linux-gnu.so,sha256=qsq2BB08AieMsA44eDCivUQ45P58jV1IJLkDdvCZ8E8,307168
3
+ ostk/io/__init__.py,sha256=IpLxatW_R2ItRy031KQcbFRNczGDpWeozg9COJH9QLA,83
4
+ ostk/io/libopen-space-toolkit-io.so.3,sha256=lhgaeJknUheoomyiYsVBnTgafRDPV6DdMYugZ2fwSOc,9337512
5
+ ostk/io/test/__init__.py,sha256=epnVn2PwdQkUDZ1msqBRO5nEZIOUBIq-IfK3IlNPijE,21
6
+ ostk/io/test/ip/__init__.py,sha256=epnVn2PwdQkUDZ1msqBRO5nEZIOUBIq-IfK3IlNPijE,21
7
+ ostk/io/test/ip/tcp/__init__.py,sha256=epnVn2PwdQkUDZ1msqBRO5nEZIOUBIq-IfK3IlNPijE,21
8
+ ostk/io/test/ip/tcp/http/__init__.py,sha256=epnVn2PwdQkUDZ1msqBRO5nEZIOUBIq-IfK3IlNPijE,21
9
+ ostk/io/test/ip/tcp/http/test_client.py,sha256=I0nRWp3HTkr2oMEbOSZJZEYVHxn7pbAdE6kBdI29mbU,1682
10
+ ostk/io/test/ip/tcp/http/test_request.py,sha256=-puxxwFqhzizeX8odF0gqgbRCXLk_zDCZkQuEUNJYx0,2205
11
+ ostk/io/test/ip/tcp/http/test_response.py,sha256=GAnbvAeNHJO9odmvxmZrW-ruuCHLYI-xYMJFQAE41lw,5866
12
+ ostk/io/test/url/__init__.py,sha256=epnVn2PwdQkUDZ1msqBRO5nEZIOUBIq-IfK3IlNPijE,21
13
+ ostk/io/test/url/test_url.py,sha256=9mPqkSq_9Xrqtdl-dK8YWw2bkvo2zd63j03WEOU1VEs,4554
14
+ open_space_toolkit_io-3.0.1.dist-info/METADATA,sha256=YWd0LrixO20XhKaQBSUp3y73QuJDJ9tEPJJnQWclfso,1672
15
+ open_space_toolkit_io-3.0.1.dist-info/WHEEL,sha256=wsubv5QUqU-p5zScRwtL3gqNUtin6rSSxODAU7loirM,111
16
+ open_space_toolkit_io-3.0.1.dist-info/top_level.txt,sha256=zOR18699uDYnafgarhL8WU_LmTZY_5NVqutv-flp_x4,5
17
+ open_space_toolkit_io-3.0.1.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
18
+ open_space_toolkit_io-3.0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.43.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py311-none-manylinux2014_x86_64
5
+
ostk/__init__.py ADDED
@@ -0,0 +1 @@
1
+ # Apache License 2.0
ostk/io/__init__.py ADDED
@@ -0,0 +1,5 @@
1
+ # Apache License 2.0
2
+
3
+ from ostk.core import *
4
+
5
+ from .OpenSpaceToolkitIOPy import *
Binary file
@@ -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"