@@ -1393,6 +1393,27 @@ def test_localhost_e2e(self):
13931393 factory .destroy (event )
13941394 event .wait ()
13951395
1396+ def test_fallback_treatments (self ):
1397+ """Instantiate a client with a JSON file and issue get_treatment() calls."""
1398+ self ._update_temp_file (splits_json ['splitChange2_1' ])
1399+ filename = os .path .join (os .path .dirname (__file__ ), 'files' , 'split_changes_temp.json' )
1400+ factory = get_factory ('localhost' ,
1401+ config = {
1402+ 'splitFile' : filename ,
1403+ 'fallbackTreatments' : FallbackTreatmentsConfiguration ("on-global" , {'fallback_feature' : "on-local" })
1404+ }
1405+ )
1406+ factory .block_until_ready (1 )
1407+ client = factory .client ()
1408+
1409+ assert client .get_treatment ("key" , "feature" ) == "on-global"
1410+ assert client .get_treatment ("key" , "fallback_feature" ) == "on-local"
1411+
1412+ event = threading .Event ()
1413+ factory .destroy (event )
1414+ event .wait ()
1415+
1416+
13961417class PluggableIntegrationTests (object ):
13971418 """Pluggable storage-based integration tests."""
13981419
@@ -3335,6 +3356,23 @@ async def test_localhost_e2e(self):
33353356 assert split .configs == {}
33363357 await factory .destroy ()
33373358
3359+ @pytest .mark .asyncio
3360+ async def test_fallback_treatments (self ):
3361+ """Instantiate a client with a JSON file and issue get_treatment() calls."""
3362+ self ._update_temp_file (splits_json ['splitChange2_1' ])
3363+ filename = os .path .join (os .path .dirname (__file__ ), 'files' , 'split_changes_temp.json' )
3364+ factory = await get_factory_async ('localhost' ,
3365+ config = {
3366+ 'splitFile' : filename ,
3367+ 'fallbackTreatments' : FallbackTreatmentsConfiguration ("on-global" , {'fallback_feature' : "on-local" })
3368+ }
3369+ )
3370+ await factory .block_until_ready (1 )
3371+ client = factory .client ()
3372+
3373+ assert await client .get_treatment ("key" , "feature" ) == "on-global"
3374+ assert await client .get_treatment ("key" , "fallback_feature" ) == "on-local"
3375+ await factory .destroy ()
33383376
33393377class PluggableIntegrationAsyncTests (object ):
33403378 """Pluggable storage-based integration tests."""
0 commit comments