Пример #1
0
 def test_drop_get_single(self):
     """
     Tests the AbstractDROP fetch routine functions correctly with a single environment drop
     """
     env_drop = create_std_env_vars()
     test_drop = AbstractDROP(uid="b", oid="b")
     test_drop.addProducer(env_drop)
     self.assertEqual(
         "/HOME/", test_drop.get_environment_variable("$env_vars.dir_var"))
     self.assertEqual(
         3, test_drop.get_environment_variable("$env_vars.int_var"))
     self.assertEqual(
         False, test_drop.get_environment_variable("$env_vars.bool_var"))
     self.assertEqual(
         0.5, test_drop.get_environment_variable("$env_vars.float_var"))
     self.assertEqual(
         {
             "first": 1,
             "second": "sec"
         },
         test_drop.get_environment_variable("$env_vars.dict_var"),
     )
     self.assertEqual(
         [1, 2.0, "3"],
         test_drop.get_environment_variable("$env_vars.list_var"))
     self.assertEqual(
         "$env_vars.non_var",
         test_drop.get_environment_variable("$env_vars.non_var"))
     self.assertEqual("$env_vars.uid",
                      test_drop.get_environment_variable("$env_vars.uid"))
Пример #2
0
 def test_drop_get_empty(self):
     """
     Tests the case where the environment drop has no name
     """
     env_name = ""
     env_drop = create_empty_env_vars(name=env_name)
     test_drop = AbstractDROP(uid="c", oid="c")
     test_drop.addProducer(env_drop)
     self.assertEqual("", test_drop.get_environment_variable(""))
     self.assertEqual("$", test_drop.get_environment_variable("$"))
Пример #3
0
 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",
         ]),
     )
Пример #4
0
 def test_autofill_environment_vars(self):
     """
     Tests the autofilling functionality of AbstractDROP
     """
     env_drop = create_std_env_vars(name="env_vars")
     test_drop = AbstractDROP(
         oid="a",
         uid="a",
         dir_var="$env_vars.dir_var",
         int_var="$env_vars.int_var",
         non_var=set(),
     )
     test_drop.addProducer(env_drop)
     test_drop.autofill_environment_variables()
     self.assertEqual("/HOME/", test_drop.parameters["dir_var"])
     self.assertEqual(3, test_drop.parameters["int_var"])
Пример #5
0
 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))