55 ENV_INTEGTESTS_DBGYM_CONFIG_FPATH ,
66 get_integtest_workspace_path ,
77)
8- from env .tuning_agent import TuningAgent
8+ from env .tuning_agent import DBMSConfig , TuningAgent
99from util .workspace import DBGymConfig
1010
1111
1212class MockTuningAgent (TuningAgent ):
13- pass
13+ def __init__ (self , * args , ** kwargs ) -> None :
14+ super ().__init__ (* args , ** kwargs )
15+ self .config_to_return = None
16+
17+ def _step (self ) -> DBMSConfig :
18+ ret = self .config_to_return
19+ assert ret is not None
20+ # This ensures you must set self.config_to_return every time
21+ ret = None
22+ return ret
1423
1524
1625class PostgresConnTests (unittest .TestCase ):
1726 dbgym_cfg : DBGymConfig
18-
27+
1928 @staticmethod
2029 def setUpClass () -> None :
2130 # If you're running the test locally, this check makes runs past the first one much faster.
@@ -26,7 +35,10 @@ def setUpClass() -> None:
2635
2736 def test_test (self ) -> None :
2837 agent = MockTuningAgent (PostgresConnTests .dbgym_cfg )
38+ config_a = DBMSConfig (["a" ], {"a" : "a" }, {"a" : ["a" ]})
39+ agent .config_to_return = config_a
2940 agent .step ()
41+ self .assertEqual (agent .get_past_config (0 ), config_a )
3042
3143
3244if __name__ == "__main__" :
0 commit comments