Skip to content

Commit

Permalink
Add tests for avalara override settings plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
mociepka committed Aug 22, 2022
1 parent a146f57 commit 36266a5
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
4 changes: 4 additions & 0 deletions saleor/plugins/avatax/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def set_configuration(
from_country_area="",
from_postal_code="53-601",
shipping_tax_code="FR000000",
override_global_tax=False,
include_taxes_in_prices=True,
):
channel = channel or channel_USD
data = {
Expand All @@ -52,6 +54,8 @@ def set_configuration(
{"name": "from_country_area", "value": from_country_area},
{"name": "from_postal_code", "value": from_postal_code},
{"name": "shipping_tax_code", "value": shipping_tax_code},
{"name": "override_global_tax", "value": override_global_tax},
{"name": "include_taxes_in_prices", "value": include_taxes_in_prices},
],
}
configuration = PluginConfiguration.objects.create(
Expand Down
37 changes: 37 additions & 0 deletions saleor/plugins/avatax/tests/test_avatax.py
Original file line number Diff line number Diff line change
Expand Up @@ -4428,3 +4428,40 @@ def test_assign_tax_code_to_object_meta_no_obj_id(
META_CODE_KEY: tax_code,
META_DESCRIPTION_KEY: description,
}


@pytest.mark.parametrize(
"global_include_taxes_in_prices, override_global_tax, "
"include_taxes_in_prices, expected_tax_included",
[(True, False, False, True), (True, True, True, True), (True, True, False, False)],
)
@patch("saleor.plugins.avatax.plugin.api_post_request_task.delay")
@override_settings(PLUGINS=["saleor.plugins.avatax.plugin.AvataxPlugin"])
def test_plugin_tax_override_setting(
api_post_request_task_mock,
global_include_taxes_in_prices,
override_global_tax,
include_taxes_in_prices,
expected_tax_included,
site_settings,
order_line,
plugin_configuration,
):
# given
site_settings.include_taxes_in_prices = global_include_taxes_in_prices
site_settings.save()

plugin_configuration(
override_global_tax=override_global_tax,
include_taxes_in_prices=include_taxes_in_prices,
)

manager = get_plugins_manager()

# when
manager.order_created(order_line.order)

# then
transaction = api_post_request_task_mock.call_args[0][1]["createTransactionModel"]
transaction_line = transaction["lines"][0]
assert transaction_line["taxIncluded"] == expected_tax_included

0 comments on commit 36266a5

Please sign in to comment.