def test_can_merge_external_config_using_path(self):
        # reset test package config for idempotent tests
        Config.set("package", {"package_param": "package_value"})

        Config.merge_with("package", "tests/core/configuration/test_config.py")
        self.assertEqual(config("package.package_param"), "package_value")
        self.assertEqual(config("package.other_param"), 3)
    def test_can_merge_external_config_with_project_config(self):
        # reset test package config for idempotent tests
        Config.set("package", {"package_param": "package_value"})

        package_default_config = {
            "PACKAGE_PARAM": "default_value",
            "OTHER_PARAM": 2
        }
        Config.merge_with("package", package_default_config)
        self.assertEqual(config("package.package_param"), "package_value")
        self.assertEqual(config("package.other_param"), 2)
Beispiel #3
0
    def register_database(self):
        from masoniteorm.query import QueryBuilder

        self.application.bind(
            "builder",
            QueryBuilder(connection_details=config("database.databases")),
        )

        self.application.bind("migrations.location",
                              "tests/integrations/databases/migrations")
        self.application.bind("seeds.location",
                              "tests/integrations/databases/seeds")

        self.application.bind("resolver", config("database.db"))
Beispiel #4
0
 def test_can_access_shared_helpers(self):
     content = self.view.render("test_helpers").get_content()
     self.assertIn(
         config("application.app_url"),
         content,
     )
     self.assertIn(url.asset("local", "avatar.jpg"), content)
     self.assertIn(url.url("welcome"), content)
 def test_config_set_value(self):
     original_value = config("cache.stores.redis.port")
     Config.set("cache.stores.redis.port", 1000)
     self.assertNotEqual(Config.get("cache.stores.redis.port"),
                         original_value)
     self.assertEqual(Config.get("cache.stores.redis.port"), 1000)
     # reset to original value
     Config.set("cache.stores.redis.port", original_value)
Beispiel #6
0
    def register_configurations(self):
        # load configuration
        self.application.bind("config.location", "tests/integrations/config")
        configuration = Configuration(self.application)
        configuration.load()
        self.application.bind("config", configuration)
        key = config("application.key")
        self.application.bind("key", key)
        self.application.bind("sign", Sign(key))

        # set locations
        self.application.bind("controllers.location",
                              "tests/integrations/controllers")
        self.application.bind("jobs.location", "tests/integrations/jobs")
        self.application.bind("mailables.location",
                              "tests/integrations/mailables")
        self.application.bind("providers.location",
                              "tests/integrations/providers")
        self.application.bind("listeners.location",
                              "tests/integrations/listeners")
        self.application.bind("validation.location",
                              "tests/integrations/validation")
        self.application.bind("tasks.location", "tests/integrations/tasks")
        self.application.bind("events.location", "tests/integrations/events")
        self.application.bind("policies.location",
                              "tests/integrations/policies")
        self.application.bind("notifications.location",
                              "tests/integrations/notifications")
        self.application.bind("resources.location",
                              "tests/integrations/resources")
        self.application.bind("models.location", "tests/integrations/app")
        self.application.bind("observers.location", "tests/integrations/app")
        self.application.bind("commands.location",
                              "tests/integrations/commands")
        self.application.bind("middlewares.location",
                              "tests/integrations/app/middlewares")

        self.application.bind("server.runner",
                              "src.masonite.commands.ServeCommand.main")
Beispiel #7
0
 def test_config_is_merged(self):
     self.assertEqual(config("test_package.param_1"), 0)
Beispiel #8
0
 def test_config_is_loaded(self):
     self.assertEqual(config("test_package.param_2"), 1)
 def test_can_load_non_foundation_config_in_project(self):
     self.assertEqual(config("package.package_param"), "package_value")
 def test_config_use_default_if_not_exist(self):
     self.assertEqual(config("some.app"), None)
     self.assertEqual(config("some.app", 0), 0)
 def test_config_helper(self):
     self.assertEqual(config("auth.guards.default"), "web")