How to use import_local_settings method in Kiwi

Best Python code snippet using Kiwi_python

test_settings.py

Source:test_settings.py Github

copy

Full Screen

...80 mock.attach_mock(prepare_syspath, "prepare_syspath")81 mock.attach_mock(import_local_settings, "import_local_settings")82 import airflow.settings83 airflow.settings.initialize()84 mock.assert_has_calls([call.prepare_syspath(), call.import_local_settings()])85 def test_import_with_dunder_all_not_specified(self):86 """87 Tests that if __all__ is specified in airflow_local_settings,88 only module attributes specified within are imported.89 """90 with SettingsContext(SETTINGS_FILE_POLICY_WITH_DUNDER_ALL, "airflow_local_settings"):91 from airflow import settings92 settings.import_local_settings()93 with self.assertRaises(AttributeError):94 settings.not_policy() # pylint: disable=no-member95 def test_import_with_dunder_all(self):96 """97 Tests that if __all__ is specified in airflow_local_settings,98 only module attributes specified within are imported.99 """100 with SettingsContext(SETTINGS_FILE_POLICY_WITH_DUNDER_ALL, "airflow_local_settings"):101 from airflow import settings102 settings.import_local_settings()103 task_instance = MagicMock()104 settings.test_policy(task_instance) # pylint: disable=no-member105 assert task_instance.run_as_user == "myself"106 @unittest.mock.patch("airflow.settings.log.debug")107 def test_import_local_settings_without_syspath(self, log_mock):108 """109 Tests that an ImportError is raised in import_local_settings110 if there is no airflow_local_settings module on the syspath.111 """112 from airflow import settings113 settings.import_local_settings()114 log_mock.assert_called_once_with("Failed to import airflow_local_settings.", exc_info=True)115 def test_policy_function(self):116 """117 Tests that task instances are mutated by the policy118 function in airflow_local_settings.119 """120 with SettingsContext(SETTINGS_FILE_POLICY, "airflow_local_settings"):121 from airflow import settings122 settings.import_local_settings()123 task_instance = MagicMock()124 settings.test_policy(task_instance) # pylint: disable=no-member125 assert task_instance.run_as_user == "myself"126 def test_pod_mutation_hook(self):127 """128 Tests that pods are mutated by the pod_mutation_hook129 function in airflow_local_settings.130 """131 with SettingsContext(SETTINGS_FILE_POD_MUTATION_HOOK, "airflow_local_settings"):132 from airflow import settings133 settings.import_local_settings()134 pod = MagicMock()135 settings.pod_mutation_hook(pod)136 assert pod.namespace == 'airflow-tests'137 def test_custom_policy(self):138 with SettingsContext(SETTINGS_FILE_CUSTOM_POLICY, "airflow_local_settings"):139 from airflow import settings140 settings.import_local_settings()141 task_instance = MagicMock()142 task_instance.owner = 'airflow'143 with self.assertRaises(AirflowClusterPolicyViolation):144 settings.task_must_have_owners(task_instance) # pylint: disable=no-member145class TestUpdatedConfigNames(unittest.TestCase):146 @conf_vars(147 {("webserver", "session_lifetime_days"): '5', ("webserver", "session_lifetime_minutes"): '43200'}148 )149 def test_updates_deprecated_session_timeout_config_val_when_new_config_val_is_default(self):150 from airflow import settings151 with self.assertWarns(DeprecationWarning):152 session_lifetime_config = settings.get_session_lifetime_config()153 minutes_in_five_days = 5 * 24 * 60154 self.assertEqual(session_lifetime_config, minutes_in_five_days)...

Full Screen

Full Screen

test_local_settings.py

Source:test_local_settings.py Github

copy

Full Screen

...68 mock.attach_mock(prepare_syspath, "prepare_syspath")69 mock.attach_mock(import_local_settings, "import_local_settings")70 import airflow.settings71 airflow.settings.initialize()72 mock.assert_has_calls([call.prepare_syspath(), call.import_local_settings()])73 def test_import_with_dunder_all_not_specified(self):74 """75 Tests that if __all__ is specified in airflow_local_settings,76 only module attributes specified within are imported.77 """78 with SettingsContext(SETTINGS_FILE_POLICY_WITH_DUNDER_ALL, "airflow_local_settings"):79 from airflow import settings80 settings.import_local_settings()81 with self.assertRaises(AttributeError):82 settings.not_policy() # pylint: disable=no-member83 def test_import_with_dunder_all(self):84 """85 Tests that if __all__ is specified in airflow_local_settings,86 only module attributes specified within are imported.87 """88 with SettingsContext(SETTINGS_FILE_POLICY_WITH_DUNDER_ALL, "airflow_local_settings"):89 from airflow import settings90 settings.import_local_settings()91 task_instance = MagicMock()92 settings.test_policy(task_instance) # pylint: disable=no-member93 assert task_instance.run_as_user == "myself"94 @unittest.mock.patch("airflow.settings.log.debug")95 def test_import_local_settings_without_syspath(self, log_mock):96 """97 Tests that an ImportError is raised in import_local_settings98 if there is no airflow_local_settings module on the syspath.99 """100 from airflow import settings101 settings.import_local_settings()102 log_mock.assert_called_once_with("Failed to import airflow_local_settings.", exc_info=True)103 def test_policy_function(self):104 """105 Tests that task instances are mutated by the policy106 function in airflow_local_settings.107 """108 with SettingsContext(SETTINGS_FILE_POLICY, "airflow_local_settings"):109 from airflow import settings110 settings.import_local_settings()111 task_instance = MagicMock()112 settings.test_policy(task_instance) # pylint: disable=no-member113 assert task_instance.run_as_user == "myself"114 def test_pod_mutation_hook(self):115 """116 Tests that pods are mutated by the pod_mutation_hook117 function in airflow_local_settings.118 """119 with SettingsContext(SETTINGS_FILE_POD_MUTATION_HOOK, "airflow_local_settings"):120 from airflow import settings121 settings.import_local_settings()122 pod = MagicMock()123 settings.pod_mutation_hook(pod)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Kiwi automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful