New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated RestCountryApi and RestCountryApiV2 BASE_URI #13
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for your PR. I do really appreciate it.
First of all, I do agree, that it makes sense to move to restcountries.com
.
I noticed you made some changes, which are actually unrelated to the goal of the PR (changing the base url).
To keep the commit clean and readable I have requested some changes.
Bumping the version of the package in the PR is not a good idea. I will bump the package version as soon, as the PR is fine.
However, bumping it on patch level seems really wrong to me, since this is definitely a breaking change (another endpoint is used).
I believe there are 2 mistakes, when it comes to get_country_by_country_code
. Please have a look at that, too.
Another thing. When you're done - could you please rebase the branch and squash the commits? This allows us to keep a clean and readable commit history.
Again, I do really appreciate the effort. So, thank you very much.
Looking forward to your changes.
README.md
Outdated
@@ -22,11 +22,13 @@ Just import the API Wrapper and start using it!:: | |||
# v1 from restcountries import RestCountryApi as rapi | |||
from restcountries import RestCountryApiV2 as rapi | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please remove this linebreak?
README.md
Outdated
def foo(name): | ||
country_list = rapi.get_countries_by_name('France') | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why move this further done? Could you please change it back?
README.md
Outdated
def foo(name): | ||
country_list = rapi.get_countries_by_name("France" ,filters=["name","currencies","capital"]) | ||
country_list = rapi.get_countries_by_name( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change the formatting of the function call? The formatting does not correspond to the black formatting rules.
restcountries/__init__.py
Outdated
@@ -2,4 +2,4 @@ | |||
from restcountries.base import RestCountryApi | |||
from restcountries.base import RestCountryApiV2 | |||
|
|||
__version__ = "1.0.0" | |||
__version__ = "1.0.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to bump the version in a dedicated PR.
restcountries/base.py
Outdated
# s = RestCountryApiV2() | ||
|
||
# s.get_countries_by_country_codes(["ke", "ug"],filters=["name","capital","currencies"]) | ||
# TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the TODO from the code.
restcountries/tests/v2/conftest.py
Outdated
@@ -0,0 +1,295 @@ | |||
import pytest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By changing the file's directory you make it really hard to compare the changes. Please change it back to the original directory structure.
restcountries/tests/v2/conftest.py
Outdated
from restcountries.base import Country | ||
from restcountries.tests.countries_data import RSA, NGR, EGY, KEN | ||
|
||
base_url = "https://restcountries.com/rest/v2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to PEP8, which the module follows, constants should be uppercased.
restcountries/tests/v2/conftest.py
Outdated
Mock requests for getting a country by its country code and filters the response. | ||
""" | ||
za_url = base_url + "/alpha/za?fields=name;capital" | ||
requests_mock.get(za_url, json=[RSA]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks wrong. The endpoint does not return a list.
restcountries/tests/v2/conftest.py
Outdated
Mock requests for getting a country by its country code. | ||
""" | ||
za_url = base_url + "/alpha/za" | ||
requests_mock.get(za_url, json=[RSA]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks wrong. The endpoint does not actually return a list.
.github/workflows/lint.yml
Outdated
@@ -20,4 +20,5 @@ jobs: | |||
python -m pip install --upgrade pre-commit | |||
python -m pip install -e '.[d]' | |||
- name: Lint | |||
run: pre-commit run --all-files --show-diff-on-failure | |||
run: | | |||
pre-commit run --all-files --show-diff-on-failure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why add the linebreak here? This does not have anything to do with the actual topic of the PR.
I have worked on the changes as requested. All is well now. |
@@ -3,7 +3,7 @@ | |||
|
|||
|
|||
class RestCountryApi: | |||
BASE_URI = "https://restcountries.eu/rest/v1" | |||
BASE_URI = "https://restcountries.com/v1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just to let you know that V1 does not exists
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amatosg thanks for letting us now. I guess we could remove the support for v1 then.
LGTM thank you. I'll open a dedicated issue to remove v1 support. |
I have modified BASE_URI to
https://restcountres.com
I have modified the tests