@@ -37,20 +37,63 @@ def test_llm_custom(self):
37
37
settings = Settings (llm = custom_llm )
38
38
self .assertEqual (settings .llm , custom_llm )
39
39
40
- def test_psycopg_url_default (self ):
40
+ def test_postgres_primary_url_default (self ):
41
41
settings = Settings ()
42
- expected = "postgresql://postgres:postgres@localhost:5432/"
43
- self .assertEqual (settings .psycopg_url , expected )
42
+ expected = "postgresql+psycopg://postgres:postgres@localhost:5432/"
43
+ self .assertEqual (str (settings .postgres_primary_url ), expected )
44
+
45
+ def test_postgres_primary_url_custom (self ):
46
+ custom_primary_url = (
47
+ "postgresql+psycopg://primary_user:primary_pass@localhost/primary_db"
48
+ )
49
+ settings = Settings (postgres_primary_url = custom_primary_url )
50
+ expected = "postgresql+psycopg://primary_user:primary_pass@localhost/primary_db"
51
+ self .assertEqual (str (settings .postgres_primary_url ), expected )
52
+
53
+ def test_postgres_standby_url_default (self ):
54
+ settings = Settings ()
55
+ expected = "postgresql+psycopg://postgres:postgres@localhost:5432/"
56
+ self .assertEqual (str (settings .postgres_standby_url ), expected )
44
57
45
- def test_psycopg_url_custom (self ):
46
- custom_url = "postgresql+psycopg2://custom_user:custom_pass@localhost/custom_db"
47
- settings = Settings (db_url = custom_url )
48
- expected = "postgresql://custom_user:custom_pass@localhost/custom_db"
49
- self .assertEqual (settings .psycopg_url , expected )
58
+ def test_postgres_standby_url_custom (self ):
59
+ custom_standby_url = (
60
+ "postgresql+psycopg://standby_user:standby_pass@localhost/standby_db"
61
+ )
62
+ settings = Settings (postgres_standby_url = custom_standby_url )
63
+ expected = "postgresql+psycopg://standby_user:standby_pass@localhost/standby_db"
64
+ self .assertEqual (str (settings .postgres_standby_url ), expected )
50
65
51
66
def test_invalid_db_url (self ):
52
67
with self .assertRaises (ValidationError ):
53
- Settings (db_url = "invalid_url" )
68
+ Settings (postgres_primary_url = "invalid_url" )
69
+ with self .assertRaises (ValidationError ):
70
+ Settings (postgres_standby_url = "invalid_url" )
71
+
72
+ def test_psycopg_primary_url_default (self ):
73
+ settings = Settings ()
74
+ expected = "postgresql://postgres:postgres@localhost:5432/"
75
+ self .assertEqual (settings .psycopg_primary_url , expected )
76
+
77
+ def test_psycopg_primary_url_custom (self ):
78
+ custom_primary_url = (
79
+ "postgresql+psycopg://primary_user:primary_pass@localhost/primary_db"
80
+ )
81
+ settings = Settings (postgres_primary_url = custom_primary_url )
82
+ expected = "postgresql://primary_user:primary_pass@localhost/primary_db"
83
+ self .assertEqual (settings .psycopg_primary_url , expected )
84
+
85
+ def test_psycopg_standby_url_default (self ):
86
+ settings = Settings ()
87
+ expected = "postgresql://postgres:postgres@localhost:5432/"
88
+ self .assertEqual (settings .psycopg_standby_url , expected )
89
+
90
+ def test_psycopg_standby_url_custom (self ):
91
+ custom_standby_url = (
92
+ "postgresql+psycopg://standby_user:standby_pass@localhost/standby_db"
93
+ )
94
+ settings = Settings (postgres_standby_url = custom_standby_url )
95
+ expected = "postgresql://standby_user:standby_pass@localhost/standby_db"
96
+ self .assertEqual (settings .psycopg_standby_url , expected )
54
97
55
98
56
99
if __name__ == "__main__" :
0 commit comments