コード例 #1
0
ファイル: test_models.py プロジェクト: 10clouds/ecommerce
    def test_validate_configuration_passes(self):
        """
        Test that site configurations with available payment processor(s) pass validation
        """
        config1 = _make_site_config(DummyProcessor.NAME)
        config2 = _make_site_config(DummyProcessor.NAME + ',' + AnotherDummyProcessor.NAME)

        self.site_config_objects.all.return_value = [config1, config2]

        validate_configuration()  # checks that no exception is thrown
コード例 #2
0
    def test_validate_configuration_passes(self):
        """
        Test that site configurations with available payment processor(s) pass validation
        """
        config1 = _make_site_config(DummyProcessor.NAME)
        config2 = _make_site_config(DummyProcessor.NAME + ',' +
                                    AnotherDummyProcessor.NAME)

        self.site_config_objects.all.return_value = [config1, config2]

        validate_configuration()  # checks that no exception is thrown
コード例 #3
0
ファイル: test_models.py プロジェクト: 10clouds/ecommerce
    def test_validate_configuration_fails(self):
        """
        Test that site configurations with unknown payment processor(s) fail validation
        """
        config1 = _make_site_config(DummyProcessor.NAME)
        config2 = _make_site_config(DummyProcessor.NAME + ',' + AnotherDummyProcessor.NAME)

        self.site_config_objects.all.return_value = [config1, config2]

        with self.assertRaises(ValidationError):
            validate_configuration()
コード例 #4
0
    def test_validate_configuration_fails(self):
        """
        Test that site configurations with unknown payment processor(s) fail validation
        """
        config1 = _make_site_config(DummyProcessor.NAME)
        config2 = _make_site_config(DummyProcessor.NAME + ',' +
                                    AnotherDummyProcessor.NAME)

        self.site_config_objects.all.return_value = [config1, config2]

        with self.assertRaises(ValidationError):
            validate_configuration()
コード例 #5
0
    def ready(self):
        super(CoreAppConfig, self).ready()

        # Ensures that the initialized Celery app is loaded when Django starts.
        # Allows Celery tasks to bind themselves to an initialized instance of the Celery library.
        from ecommerce import celery_app  # pylint: disable=unused-variable

        from ecommerce.core.models import validate_configuration
        # Operational error means database did not contain SiteConfiguration table - ok to skip since it means there
        # are no SiteConfiguration models to validate. Also, this exception was only observed in tests and test run
        # just fine with this suppression - most likely test code hit this line before the DB is populated
        try:
            # Here we're are consciously violating Django's warning about not interacting with DB in AppConfig.ready
            # We know what we're doing, have considered a couple of other approaches and discussed it in great length:
            # https://github.com/edx/ecommerce/pull/630#discussion-diff-58026881
            validate_configuration()
        except DatabaseError:
            log.exception(self.OPERATIONAL_ERROR_MESSAGE)