Example #1
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("$"))
Example #2
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"))
Example #3
0
 def test_get_dlg_vars(self):
     test_drop = AbstractDROP(
         oid="a",
         uid="a",
         dlg_root="$DLG_ROOT",
         non_dlg_var="$DLG_NONEXISTS",
         non_var=set(),
     )
     test_drop.autofill_environment_variables()
     self.assertEqual(getDlgDir(), test_drop.parameters["dlg_root"])
     self.assertEqual(getDlgDir(),
                      test_drop.get_environment_variable("$DLG_ROOT"))
     self.assertEqual("$DLG_NONEXISTS", test_drop.parameters["non_dlg_var"])
     self.assertEqual("$DLG_NONEXISTS",
                      test_drop.get_environment_variable("$DLG_NONEXISTS"))
Example #4
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",
         ]),
     )