# -*- coding: utf-8 -*-
from unittest.mock import patch

from django.test import SimpleTestCase, override_settings

from .checks import dummy_payment_is_explicitly_allowed


class DummyPaymentSafetyCheckTests(SimpleTestCase):
    @override_settings(DEBUG=True)
    def test_development_is_allowed(self):
        self.assertEqual(dummy_payment_is_explicitly_allowed(None), [])

    @override_settings(DEBUG=False)
    def test_production_is_rejected_by_default(self):
        with patch("ocyan.plugin.payment_dummy.checks.sys.argv", ["manage.py"]):
            errors = dummy_payment_is_explicitly_allowed(None)

        self.assertEqual([error.id for error in errors], ["payment_dummy.E001"])

    @override_settings(DEBUG=False, OCYAN_DUMMY_PAYMENT_ALLOWED=True)
    def test_explicit_non_production_override_is_allowed(self):
        self.assertEqual(dummy_payment_is_explicitly_allowed(None), [])
