@@ -74,3 +74,75 @@ def test_cache_no_rediness(self):
7474 response = self .client .get ('/readiness/' )
7575 self .assertTrue (response .status_code == 500 )
7676 self .assertTrue (response .content == b'down' )
77+
78+ @override_settings (
79+ SIMPLE_HEALTH_CHECKS = {
80+ 'simple_health_check.checks.ps.DiskUsage' : None ,
81+ },
82+ )
83+ def test_ps_disk_usage_no_value (self ):
84+ apps .get_app_config ('simple_health_check' ).register_checks ()
85+
86+ response = self .client .get ('/readiness/' )
87+ self .assertTrue (response .status_code == 200 )
88+ self .assertTrue (response .content == b'ok' )
89+
90+ @override_settings (
91+ SIMPLE_HEALTH_CHECKS = {
92+ 'simple_health_check.checks.ps.DiskUsage' : dict (max_usage_percent = 99 ),
93+ },
94+ )
95+ def test_ps_disk_usage (self ):
96+ apps .get_app_config ('simple_health_check' ).register_checks ()
97+
98+ response = self .client .get ('/readiness/' )
99+ self .assertTrue (response .status_code == 200 )
100+ self .assertTrue (response .content == b'ok' )
101+
102+ @override_settings (
103+ SIMPLE_HEALTH_CHECKS = {
104+ 'simple_health_check.checks.ps.DiskUsage' : dict (max_usage_percent = 0.001 ),
105+ },
106+ )
107+ def test_ps_disk_usage_no_rediness (self ):
108+ apps .get_app_config ('simple_health_check' ).register_checks ()
109+
110+ response = self .client .get ('/readiness/' )
111+ self .assertTrue (response .status_code == 500 )
112+ self .assertTrue (response .content == b'down' )
113+
114+ @override_settings (
115+ SIMPLE_HEALTH_CHECKS = {
116+ 'simple_health_check.checks.ps.MemoryUsage' : None ,
117+ },
118+ )
119+ def test_ps_memory_usage_no_value (self ):
120+ apps .get_app_config ('simple_health_check' ).register_checks ()
121+
122+ response = self .client .get ('/readiness/' )
123+ self .assertTrue (response .status_code == 200 )
124+ self .assertTrue (response .content == b'ok' )
125+
126+ @override_settings (
127+ SIMPLE_HEALTH_CHECKS = {
128+ 'simple_health_check.checks.ps.MemoryUsage' : dict (min_memory_mb = 10 ),
129+ },
130+ )
131+ def test_ps_memory_usage (self ):
132+ apps .get_app_config ('simple_health_check' ).register_checks ()
133+
134+ response = self .client .get ('/readiness/' )
135+ self .assertTrue (response .status_code == 200 )
136+ self .assertTrue (response .content == b'ok' )
137+
138+ @override_settings (
139+ SIMPLE_HEALTH_CHECKS = {
140+ 'simple_health_check.checks.ps.MemoryUsage' : dict (min_memory_mb = 100_000 ),
141+ },
142+ )
143+ def test_ps_memory_usage_no_rediness (self ):
144+ apps .get_app_config ('simple_health_check' ).register_checks ()
145+
146+ response = self .client .get ('/readiness/' )
147+ self .assertTrue (response .status_code == 500 )
148+ self .assertTrue (response .content == b'down' )
0 commit comments