44def test_config (worker ):
55 """ Test different config passing options. """
66
7+ # Default config values
78 worker .start ()
89
910 cfg = json .loads (
1011 worker .send_task ("tests.tasks.general.GetConfig" , {}, block = True ))
1112
12- assert "mongodb_jobs" in cfg
13+ assert cfg [ "mongodb_jobs" ] == "mongodb://127.0.0.1:27017/mrq"
1314 assert cfg .get ("additional_unexpected_config" ) is None
1415
1516 worker .stop ()
1617
18+ # Values from config file
1719 worker .start (flags = "--config tests/fixtures/config2.py" )
1820
1921 cfg = json .loads (
2022 worker .send_task ("tests.tasks.general.GetConfig" , {}, block = True ))
2123
24+ assert cfg ["mongodb_jobs" ] == "mongodb://127.0.0.1:27017/mrq?connectTimeoutMS=4242"
2225 assert cfg ["name" ] == "testworker"
2326 assert cfg .get ("additional_unexpected_config" ) == "1"
2427
2528 worker .stop ()
2629
27- worker .start (flags = "--config tests/fixtures/config2.py --name xxx" )
30+ # CLI > Config file && CLI > ENV
31+ worker .start (flags = "--config tests/fixtures/config2.py --name xxx" , env = {"MRQ_NAME" : "yyy" })
2832
2933 cfg = json .loads (
3034 worker .send_task ("tests.tasks.general.GetConfig" , {}, block = True ))
@@ -33,3 +37,14 @@ def test_config(worker):
3337 assert cfg .get ("additional_unexpected_config" ) == "1"
3438
3539 worker .stop ()
40+
41+ # ENV > Config file
42+ worker .start (flags = "--config tests/fixtures/config2.py" , env = {"MRQ_NAME" : "yyy" })
43+
44+ cfg = json .loads (
45+ worker .send_task ("tests.tasks.general.GetConfig" , {}, block = True ))
46+
47+ assert cfg ["name" ] == "yyy"
48+ assert cfg .get ("additional_unexpected_config" ) == "1"
49+
50+ worker .stop ()
0 commit comments