Пример #1
0
    def test_run_script_does_not_delete_workunit(self):
        conn = hpycc.Connection("user", test_conn=False)
        check_wu_ecl = "ecl getwuid -u user -pw 1234 -s localhost -n test_run_script_deletes_workunit"
        good_script = ("#WORKUNIT('name','test_run_script_deletes_workunit');"
                       "OUTPUT(2);")

        with TemporaryDirectory() as d:
            p = os.path.join(d, "test.ecl")
            with open(p, "w+") as file:
                file.write(good_script)
            hpycc.run_script(conn, p, delete_workunit=False)
        res = conn._run_command(check_wu_ecl)
        self.assertRegex(res.stdout, "W[0-9]{8}-[0-9]{6}")
Пример #2
0
    def test_run_script_does_nothing_when_not_using_stored(self):
        conn = hpycc.Connection("user", test_conn=False)
        file_name = "test_run_script_does_nothing_when_not_using_stored_"
        good_script = "str := 'abc' : STORED('str');" \
                      " z := DATASET([{{str + str}}]," \
                      " {{STRING str;}}); OUTPUT(z,,'~{}', " \
                      "EXPIRE(1));".format(file_name)

        with TemporaryDirectory() as d:
            p = os.path.join(d, "test.ecl")
            with open(p, "w+") as file:
                file.write(good_script)
            hpycc.run_script(conn, p, stored={'b': 'Shouldbethecorrectoutput'})
        res = hpycc.get_thor_file(conn, file_name)
        expected = pd.DataFrame({"str": ["abcabc"], "__fileposition__": [0]})
        pd.testing.assert_frame_equal(expected.sort_index(axis=1), res.sort_index(axis=1), check_dtype=False)
Пример #3
0
 def test_run_script_returns_true(self):
     conn = hpycc.Connection("user", test_conn=False)
     good_script = "OUTPUT(2);"
     with TemporaryDirectory() as d:
         p = os.path.join(d, "test.ecl")
         with open(p, "w+") as file:
             file.write(good_script)
         res = hpycc.run_script(conn, p, delete_workunit=False)
     self.assertTrue(res)
Пример #4
0
 def test_run_script_uses_default_parameters(self, mock):
     conn = Connection("user", test_conn=False)
     run_script(conn, "abc.ecl")
     mock.assert_called_with("abc.ecl", True, True, None)
Пример #5
0
 def test_run_script_uses_custom_parameters(self, mock):
     conn = Connection("user", test_conn=False)
     run_script(conn, "abc.ecl", False, False, {'a': 'Testing'})
     mock.assert_called_with("abc.ecl", False, False, {'a': 'Testing'})