Skip to content
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

Merged
merged 2 commits into from Oct 7, 2021
Merged

Updated RestCountryApi and RestCountryApiV2 BASE_URI #13

merged 2 commits into from Oct 7, 2021

Conversation

allansifuna
Copy link
Contributor

I have modified BASE_URI to https://restcountres.com
I have modified the tests

Copy link
Owner

@SteinRobert SteinRobert left a 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


Copy link
Owner

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')
```
Copy link
Owner

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(
Copy link
Owner

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.

@@ -2,4 +2,4 @@
from restcountries.base import RestCountryApi
from restcountries.base import RestCountryApiV2

__version__ = "1.0.0"
__version__ = "1.0.1"
Copy link
Owner

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.

# s = RestCountryApiV2()

# s.get_countries_by_country_codes(["ke", "ug"],filters=["name","capital","currencies"])
# TODO
Copy link
Owner

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.

@@ -0,0 +1,295 @@
import pytest
Copy link
Owner

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.

from restcountries.base import Country
from restcountries.tests.countries_data import RSA, NGR, EGY, KEN

base_url = "https://restcountries.com/rest/v2"
Copy link
Owner

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.

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])
Copy link
Owner

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.

Mock requests for getting a country by its country code.
"""
za_url = base_url + "/alpha/za"
requests_mock.get(za_url, json=[RSA])
Copy link
Owner

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.

@@ -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
Copy link
Owner

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.

Updated BASE_URI#12

Update Base URI #12

updated lint.yml

Update Base URI #12

modifed readme.md

Bug fixes

Updated BASE_URI

Updated BASE_URI
@allansifuna
Copy link
Contributor Author

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"
Copy link

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

Copy link
Owner

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.

@SteinRobert
Copy link
Owner

LGTM thank you. I'll open a dedicated issue to remove v1 support.

@SteinRobert SteinRobert merged commit df22994 into SteinRobert:master Oct 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants