Esempio n. 1
0
    def test_hashdelete_ok_str(self):
        """
        If hashdelete gets a string argument, it should work
        """
        try:
            paths = self.paths + " %s/hashnot" % self.hdir
            h = hpss.HSI(verbose=("verbose" in testhelp.testargs()))
            # make sure the hashables all have a checksum stored
            x = h.hashlist(self.plist)
            for path in self.plist:
                if util.rgxin("\(?none\)?  %s" % path, x):
                    h.hashcreate(path)

            # run hashdelete on the string
            result = h.hashdelete(paths)
            h.quit()

            # verify the results
            self.expected_in("hashdelete", result)
            for path in self.paths.split():
                exp = "hash deleted: \(?md5\)? %s" % path
                self.expected_in(exp, result)
            exp = "hash deleted: \(?md5\)? %s/hashnot" % self.hdir
            self.assertFalse(util.rgxin(exp, result),
                             "'%s' not expected in %s" %
                             (exp, util.line_quote(result)))
        except hpss.HSIerror as e:
            if MSG.hpss_unavailable in str(e):
                pytest.skip(str(e))
Esempio n. 2
0
    def test_hashdelete_ok_list(self):
        """
        If hashdelete get a list argument, it should work
        """
        try:
            plist = self.plist + [self.hdir + "/hashnot"]
            h = hpss.HSI(verbose=("verbose" in testhelp.testargs()))
            # make sure the hashables all have a checksum stored
            x = h.hashlist(self.plist)
            for path in self.plist:
                if util.rgxin("\(?none\)?  %s" % path, x):
                    h.hashcreate(path)

            # run hashdelete on the list
            result = h.hashdelete(plist)
            h.quit()

            # verify the results
            self.expected_in("hashdelete", result)
            for path in self.plist:
                self.expected_in("hash deleted: md5 %s" % path, result)
            exp = "\(?none\)?  %s/hashnot" % self.hdir
            self.assertTrue(exp not in result,
                            "'%s' not expected in %s" %
                            (exp,
                             util.line_quote(result)))
        except hpss.HSIerror as e:
            if MSG.hpss_unavailable in str(e):
                pytest.skip(str(e))
Esempio n. 3
0
    def test_line_quote(self):
        """
        line_quote is supposed to wrap a string in line-based quote marks
        (three double quotes in a row) on separate lines. Any single or double
        quotes wrapping the incoming string are stripped off in the output.
        """
        self.dbgfunc()
        exp = '\n"""\nabc\n"""'
        act = util.line_quote('abc')
        self.expected(exp, act)

        exp = '\n"""\nabc\n"""'
        act = util.line_quote("'abc'")
        self.expected(exp, act)

        exp = '\n"""\nabc\n"""'
        act = util.line_quote('"abc"')
        self.expected(exp, act)
Esempio n. 4
0
    def test_line_quote(self):
        """
        line_quote is supposed to wrap a string in line-based quote marks
        (three double quotes in a row) on separate lines. Any single or double
        quotes wrapping the incoming string are stripped off in the output.
        """
        self.dbgfunc()
        exp = '\n"""\nabc\n"""'
        act = util.line_quote('abc')
        self.expected(exp, act)

        exp = '\n"""\nabc\n"""'
        act = util.line_quote("'abc'")
        self.expected(exp, act)

        exp = '\n"""\nabc\n"""'
        act = util.line_quote('"abc"')
        self.expected(exp, act)
Esempio n. 5
0
 def test_dlog(self):
     """
     Test method dlog on daemon object
     """
     lfname = self.tmpdir('daemon.dlog.log')
     lf = CrawlConfig.log(logpath=lfname)
     a = daemon.Daemon(self.tmpdir("daemon_pid"), logger=lf)
     logmsg = "testing the dlog method of %s" % a
     a.dlog(logmsg)
     self.assertTrue(
         logmsg in util.contents(lfname), "Expected '%s' in '%s'" %
         (logmsg, util.line_quote(util.contents(lfname))))
Esempio n. 6
0
 def test_dlog(self):
     """
     Test method dlog on daemon object
     """
     lfname = self.tmpdir('daemon.dlog.log')
     lf = CrawlConfig.log(logpath=lfname)
     a = daemon.Daemon(self.tmpdir("daemon_pid"), logger=lf)
     logmsg = "testing the dlog method of %s" % a
     a.dlog(logmsg)
     self.assertTrue(logmsg in util.contents(lfname),
                     "Expected '%s' in '%s'" %
                     (logmsg,
                      util.line_quote(util.contents(lfname))))
Esempio n. 7
0
 def script_help(self, cmdname, helplist):
     """
     ScriptBase: Make sure 'tcc help' generates something reasonable
     """
     cmd = pexpect.which(cmdname)
     if cmd is None:
         cmd = "bin/" + cmdname
     result = pexpect.run("%s help" % cmd)
     self.assertFalse(
         "Traceback" in result,
         "'Traceback' not expected in %s" % U.line_quote(result))
     for item in helplist:
         self.assertTrue(item in result,
                         "Expected '%s' in '%s'" % (item, result))
Esempio n. 8
0
 def script_help(self, cmdname, helplist):
     """
     ScriptBase: Make sure 'tcc help' generates something reasonable
     """
     cmd = pexpect.which(cmdname)
     if cmd is None:
         cmd = "bin/" + cmdname
     result = pexpect.run("%s help" % cmd)
     self.assertFalse("Traceback" in result,
                      "'Traceback' not expected in %s" %
                      U.line_quote(result))
     for item in helplist:
         self.assertTrue(item in result,
                         "Expected '%s' in '%s'" % (item, result))
Esempio n. 9
0
    def test_chdir_perm(self):
        """
        Change dir in HPSS to a non-accessible directory
        """
        try:
            h = hpss.HSI(verbose=("verbose" in testhelp.testargs()))
            result = h.chdir("cli_test/unreadable")
            h.quit()

            exp = "hpss_Chdir: Access denied"
            self.assertTrue(exp in result,
                            "Expected '%s' in %s" %
                            (exp, util.line_quote(result)))
        except hpss.HSIerror as e:
            if MSG.hpss_unavailable in str(e):
                pytest.skip(str(e))
Esempio n. 10
0
    def test_chdir_notdir(self):
        """
        Change dir in HPSS to a non directory
        """
        try:
            h = hpss.HSI(verbose=("verbose" in testhelp.testargs()))
            result = h.chdir("hic_test/crawler.tar")
            h.quit()

            exp = "Not a directory"
            self.assertTrue(exp in result,
                            "Expected '%s' in %s" %
                            (exp, util.line_quote(result)))
        except hpss.HSIerror as e:
            if MSG.hpss_unavailable in str(e):
                pytest.skip(str(e))