-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapt CI pipeline to country template v7
- Loading branch information
Showing
13 changed files
with
79 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
pytest_plugins = [ | ||
"tests.fixtures.appclient", | ||
"tests.fixtures.entities", | ||
"tests.fixtures.extensions", | ||
"tests.fixtures.simulations", | ||
"tests.fixtures.taxbenefitsystems", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from importlib import metadata | ||
|
||
import pytest | ||
|
||
|
||
@pytest.fixture() | ||
def test_country_package_name(): | ||
return "openfisca_country_template" | ||
|
||
|
||
@pytest.fixture() | ||
def test_extension_package_name(): | ||
return "openfisca_extension_template" | ||
|
||
|
||
@pytest.fixture() | ||
def distribution(test_country_package_name): | ||
return metadata.distribution(test_country_package_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +0,0 @@ | ||
import pkg_resources | ||
|
||
TEST_COUNTRY_PACKAGE_NAME = "openfisca_country_template" | ||
distribution = pkg_resources.get_distribution(TEST_COUNTRY_PACKAGE_NAME) | ||
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,39 @@ | ||
# -*- coding: utf-8 -*- | ||
from http import client | ||
|
||
from http.client import OK | ||
import pytest | ||
|
||
from openfisca_core.scripts import build_tax_benefit_system | ||
from openfisca_web_api.app import create_app | ||
|
||
TEST_COUNTRY_PACKAGE_NAME = "openfisca_country_template" | ||
TEST_EXTENSION_PACKAGE_NAMES = ["openfisca_extension_template"] | ||
|
||
tax_benefit_system = build_tax_benefit_system( | ||
TEST_COUNTRY_PACKAGE_NAME, extensions=TEST_EXTENSION_PACKAGE_NAMES, reforms=None | ||
) | ||
@pytest.fixture() | ||
def tax_benefit_system(test_country_package_name, test_extension_package_name): | ||
return build_tax_benefit_system( | ||
test_country_package_name, | ||
extensions=[test_extension_package_name], | ||
reforms=None, | ||
) | ||
|
||
|
||
extended_subject = create_app(tax_benefit_system).test_client() | ||
@pytest.fixture() | ||
def extended_subject(tax_benefit_system): | ||
return create_app(tax_benefit_system).test_client() | ||
|
||
|
||
def test_return_code(): | ||
def test_return_code(extended_subject): | ||
parameters_response = extended_subject.get("/parameters") | ||
assert parameters_response.status_code == OK | ||
assert parameters_response.status_code == client.OK | ||
|
||
|
||
def test_return_code_existing_parameter(): | ||
def test_return_code_existing_parameter(extended_subject): | ||
extension_parameter_response = extended_subject.get( | ||
"/parameter/local_town.child_allowance.amount" | ||
) | ||
assert extension_parameter_response.status_code == OK | ||
assert extension_parameter_response.status_code == client.OK | ||
|
||
|
||
def test_return_code_existing_variable(): | ||
def test_return_code_existing_variable(extended_subject): | ||
extension_variable_response = extended_subject.get( | ||
"/variable/local_town_child_allowance" | ||
) | ||
assert extension_variable_response.status_code == OK | ||
assert extension_variable_response.status_code == client.OK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,10 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from . import distribution | ||
|
||
|
||
def test_package_name_header(test_client): | ||
def test_package_name_header(test_client, distribution): | ||
name = distribution.metadata.get("Name").lower() | ||
parameters_response = test_client.get("/parameters") | ||
assert parameters_response.headers.get("Country-Package") == distribution.key | ||
assert parameters_response.headers.get("Country-Package") == name | ||
|
||
|
||
def test_package_version_header(test_client): | ||
def test_package_version_header(test_client, distribution): | ||
version = distribution.metadata.get("Version") | ||
parameters_response = test_client.get("/parameters") | ||
assert ( | ||
parameters_response.headers.get("Country-Package-Version") | ||
== distribution.version | ||
) | ||
assert parameters_response.headers.get("Country-Package-Version") == version |