diff --git a/ecommerce/factories.py b/ecommerce/factories.py index f7a54734e8..cc0bcb3a80 100644 --- a/ecommerce/factories.py +++ b/ecommerce/factories.py @@ -109,6 +109,7 @@ class Meta: class OrderFactory(DjangoModelFactory): total_price_paid = fuzzy.FuzzyDecimal(10.00, 10.00) purchaser = SubFactory(UserFactory) + state = models.OrderStatus.PENDING class Meta: model = models.Order diff --git a/flexiblepricing/management/commands/update_exchange_rates_test.py b/flexiblepricing/management/commands/update_exchange_rates_test.py deleted file mode 100644 index 1fafa37f5f..0000000000 --- a/flexiblepricing/management/commands/update_exchange_rates_test.py +++ /dev/null @@ -1,52 +0,0 @@ -""" -Test for management command generating exchange rates -""" - -from unittest.mock import patch - -from django.test import TestCase -from django.test.utils import override_settings - -from flexiblepricing.management.commands import update_exchange_rates -from flexiblepricing.models import CurrencyExchangeRate -from flexiblepricing.tasks import get_open_exchange_rates_url - - -@patch("flexiblepricing.tasks.requests.get") -class GenerateExchangeRatesTest(TestCase): - """ - Tests for generate_exchange_rates management command - """ - - @classmethod - def setUpTestData(cls): - cls.command = update_exchange_rates.Command() - - def setUp(self): - super(GenerateExchangeRatesTest, self).setUp() # noqa: UP008 - self.data = { - "extraneous information": "blah blah blah", - "rates": {"CBA": "3.5", "FED": "1.9", "RQP": "0.5"}, - } - - @override_settings( - OPEN_EXCHANGE_RATES_APP_ID="foo_id", - OPEN_EXCHANGE_RATES_URL="http://foo.bar.com", - ) - def test_currency_exchange_rate_command(self, mocked_request): - """ - Assert currency exchange rates are created using management command - """ - mocked_request.return_value.json.return_value = self.data - mocked_request.return_value.status_code = 200 - assert CurrencyExchangeRate.objects.count() == 0 - self.command.handle("generate_exchange_rates") - called_args, _ = mocked_request.call_args - assert called_args[0] == get_open_exchange_rates_url("latest.json") - assert CurrencyExchangeRate.objects.count() == 3 - currency_cba = CurrencyExchangeRate.objects.get(currency_code="CBA") - assert currency_cba.exchange_rate == 3.5 - currency_fed = CurrencyExchangeRate.objects.get(currency_code="FED") - assert currency_fed.exchange_rate == 1.9 - currency_rqp = CurrencyExchangeRate.objects.get(currency_code="RQP") - assert currency_rqp.exchange_rate == 0.5