@@ -1527,29 +1527,31 @@ def test_health_db_unreachable_returns_503(self) -> None:
15271527 os .environ .pop ("CRE_ENABLE_HEALTH" , None )
15281528
15291529 def test_capabilities_endpoint_returns_myopencre_key (self ) -> None :
1530- os .environ .pop ("CRE_ENABLE_MYOPENCRE" , None )
1531- with self .app .test_client () as client :
1532- response = client .get ("/api/capabilities" )
1533- self .assertEqual (200 , response .status_code )
1534- body = json .loads (response .data .decode ())
1535- self .assertIn ("myopencre" , body )
1536- self .assertIsInstance (body ["myopencre" ], bool )
1530+ """GET /api/capabilities returns 200 with a boolean myopencre key."""
1531+ with patch .dict (os .environ , {}, clear = False ):
1532+ os .environ .pop ("CRE_ENABLE_MYOPENCRE" , None )
1533+ with self .app .test_client () as client :
1534+ response = client .get ("/api/capabilities" )
1535+ self .assertEqual (200 , response .status_code )
1536+ body = json .loads (response .data .decode ())
1537+ self .assertIn ("myopencre" , body )
1538+ self .assertIsInstance (body ["myopencre" ], bool )
15371539
15381540 def test_capabilities_myopencre_false_by_default (self ) -> None :
1539- os .environ .pop ("CRE_ENABLE_MYOPENCRE" , None )
1540- with self .app .test_client () as client :
1541- response = client .get ("/api/capabilities" )
1542- self .assertEqual (200 , response .status_code )
1543- body = json .loads (response .data .decode ())
1544- self .assertFalse (body ["myopencre" ])
1541+ """myopencre is False when CRE_ENABLE_MYOPENCRE is unset."""
1542+ with patch .dict (os .environ , {}, clear = False ):
1543+ os .environ .pop ("CRE_ENABLE_MYOPENCRE" , None )
1544+ with self .app .test_client () as client :
1545+ response = client .get ("/api/capabilities" )
1546+ self .assertEqual (200 , response .status_code )
1547+ body = json .loads (response .data .decode ())
1548+ self .assertFalse (body ["myopencre" ])
15451549
15461550 def test_capabilities_myopencre_true_when_flag_set (self ) -> None :
1547- os . environ [ "CRE_ENABLE_MYOPENCRE" ] = "1 "
1548- try :
1551+ """myopencre is True when CRE_ENABLE_MYOPENCRE is set to a truthy value."" "
1552+ with patch . dict ( os . environ , { "CRE_ENABLE_MYOPENCRE" : "1" }, clear = False ) :
15491553 with self .app .test_client () as client :
15501554 response = client .get ("/api/capabilities" )
15511555 self .assertEqual (200 , response .status_code )
15521556 body = json .loads (response .data .decode ())
15531557 self .assertTrue (body ["myopencre" ])
1554- finally :
1555- os .environ .pop ("CRE_ENABLE_MYOPENCRE" , None )
0 commit comments