def test_drop_get_multiEnv(self): """ Tests the AbstractDROP fetch routine with multiple environment drops """ env1_name = "env_vars" env2_name = "more_vars" env1_drop = create_std_env_vars(name=env1_name) env2_drop = EnvironmentVarDROP(oid="d", uid="d", nm=env2_name, dir_var="/DIFFERENT/", int_var=4) test_drop = AbstractDROP(uid="c", oid="c") test_drop.addProducer(env1_drop) test_drop.addProducer(env2_drop) self.assertEqual( "/HOME/", test_drop.get_environment_variable(f"${env1_name}.dir_var")) self.assertEqual( "/DIFFERENT/", test_drop.get_environment_variable(f"${env2_name}.dir_var")) self.assertEqual( 3, test_drop.get_environment_variable(f"${env1_name}.int_var")) self.assertEqual( 4, test_drop.get_environment_variable(f"${env2_name}.int_var")) self.assertEqual( f"{env1_name}.int_var", test_drop.get_environment_variable(f"{env1_name}.int_var"), ) self.assertEqual(f".int_var", test_drop.get_environment_variable(f".int_var")) self.assertEqual( f"$third_env.int_var", test_drop.get_environment_variable(f"$third_env.int_var"), ) self.assertEqual( [ "/HOME/", "/DIFFERENT/", 3, 4, f"${env1_name}.non_var", "$fake.var" ], test_drop.get_environment_variables([ f"${env1_name}.dir_var", f"${env2_name}.dir_var", f"${env1_name}.int_var", f"${env2_name}.int_var", f"${env1_name}.non_var", "$fake.var", ]), )
def test_drop_get_multiple(self): """ Tests the AbstractDROP multiple fetch routine functions correctly with a single environment drop """ env_name = "env_vars" env_drop = create_std_env_vars(name=env_name) test_drop = AbstractDROP(uid="b", oid="b") test_drop.addProducer(env_drop) expected_vars = [ f"${env_name}.uid", "/HOME/", 3, False, 0.5, { "first": 1, "second": "sec" }, [1, 2.0, "3"], f"${env_name}.non_var", ] query_keys = [ "uid", "dir_var", "int_var", "bool_var", "float_var", "dict_var", "list_var", "non_var", ] query_keys = [f"${env_name}.{x}" for x in query_keys] # Build queries of the correct form # Add some purposefully malformed vars extra_keys = ["dir_var", "$non_store.non_var"] query_keys.extend(extra_keys) expected_vars.extend(extra_keys) self.assertEqual(expected_vars, test_drop.get_environment_variables(query_keys))