Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DuniterPy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
python
DuniterPy
Commits
594fed92
Commit
594fed92
authored
4 years ago
by
Vincent Texier
Browse files
Options
Downloads
Patches
Plain Diff
[fix] fix bug in API.reverse_url
Cover with tests
parent
169b0265
No related branches found
No related tags found
2 merge requests
!119
Release 0.61.0
,
!90
Add GraphQL GVA API support
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
duniterpy/api/client.py
+5
-2
5 additions, 2 deletions
duniterpy/api/client.py
tests/api/bma/test_bma.py
+37
-1
37 additions, 1 deletion
tests/api/bma/test_bma.py
with
42 additions
and
3 deletions
duniterpy/api/client.py
+
5
−
2
View file @
594fed92
...
@@ -232,11 +232,14 @@ class API:
...
@@ -232,11 +232,14 @@ class API:
api_path
=
self
.
connection_handler
.
path
,
api_path
=
self
.
connection_handler
.
path
,
)
)
else
:
else
:
url
=
"
{scheme}://{server}:{port}
/
"
.
format
(
url
=
"
{scheme}://{server}:{port}
"
.
format
(
scheme
=
scheme
,
server
=
server
,
port
=
port
scheme
=
scheme
,
server
=
server
,
port
=
port
)
)
return
url
+
path
if
len
(
path
.
strip
())
>
0
:
return
f
"
{
url
}
/
{
path
}
"
return
url
async
def
requests_get
(
self
,
path
:
str
,
**
kwargs
:
Any
)
->
ClientResponse
:
async
def
requests_get
(
self
,
path
:
str
,
**
kwargs
:
Any
)
->
ClientResponse
:
"""
"""
...
...
This diff is collapsed.
Click to expand it.
tests/api/bma/test_bma.py
+
37
−
1
View file @
594fed92
...
@@ -21,7 +21,7 @@ import unittest
...
@@ -21,7 +21,7 @@ import unittest
import
aiohttp
import
aiohttp
from
duniterpy.api.client
import
API
,
parse_error
from
duniterpy.api.client
import
API
,
parse_error
from
duniterpy.api.endpoint
import
BMAEndpoint
from
duniterpy.api.endpoint
import
BMAEndpoint
,
SecuredBMAEndpoint
,
GVAEndpoint
class
TestBmaApi
(
unittest
.
TestCase
):
class
TestBmaApi
(
unittest
.
TestCase
):
...
@@ -53,6 +53,42 @@ class TestBmaApi(unittest.TestCase):
...
@@ -53,6 +53,42 @@ class TestBmaApi(unittest.TestCase):
self
.
loop
.
run_until_complete
(
go
())
self
.
loop
.
run_until_complete
(
go
())
def
test_reverse_url_complete_bmas
(
self
):
async
def
go
():
endpoint
=
SecuredBMAEndpoint
(
"
test.com
"
,
"
124.2.2.1
"
,
"
2001:0db8:0000:85a3:0000:0000:ac1f:8001
"
,
9092
,
"
api_path
"
,
)
session
=
aiohttp
.
ClientSession
()
api
=
API
(
endpoint
.
conn_handler
(
session
))
self
.
assertEqual
(
api
.
reverse_url
(
"
http
"
,
"
/test/url
"
),
"
http://test.com:9092/api_path/test/url
"
,
)
await
session
.
close
()
self
.
loop
.
run_until_complete
(
go
())
def
test_reverse_url_complete_gva
(
self
):
async
def
go
():
endpoint
=
GVAEndpoint
(
"
S
"
,
"
test.com
"
,
"
124.2.2.1
"
,
"
2001:0db8:0000:85a3:0000:0000:ac1f:8001
"
,
9092
,
"
gva
"
,
)
session
=
aiohttp
.
ClientSession
()
api
=
API
(
endpoint
.
conn_handler
(
session
))
self
.
assertEqual
(
api
.
reverse_url
(
"
https
"
,
""
),
"
https://test.com:9092/gva
"
)
await
session
.
close
()
self
.
loop
.
run_until_complete
(
go
())
def
test_reverse_url_only_ipv4
(
self
):
def
test_reverse_url_only_ipv4
(
self
):
async
def
go
():
async
def
go
():
endpoint
=
BMAEndpoint
(
""
,
"
124.2.2.1
"
,
""
,
9092
)
endpoint
=
BMAEndpoint
(
""
,
"
124.2.2.1
"
,
""
,
9092
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment