def test_hashlist_ok_glob(self): """ If hashlist gets a wildcard argument, it should work """ try: vbval = ("verbose" in testhelp.testargs()) 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 the test payload result = h.hashlist("%s/hash*" % self.hdir) h.quit() self.expected_in("hashlist", result) for path in self.plist: exp = "\(?md5\)? %s" % path self.expected_in(exp, result) exp = "\(?none\)? %s/hashnot" % self.hdir self.expected_in(exp, result) except hpss.HSIerror as e: if MSG.hpss_unavailable in str(e): pytest.skip(str(e))
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))
def test_hashverify_ok_glob(self): """ Issue "hashverify" in hsi on a wildcard, return results """ self.dbgfunc() try: glop = "/home/tpb/hic_test/hash*" 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 "\(?none\)? %s" % path in x: h.hashcreate(path) # run hashverify on the glob path result = h.hashverify(glop) h.quit() # verify the results: we should see "OK" for the hashables and an # error for hashnot self.expected_in("hashverify", result) for path in self.plist: exp = "%s: \(?md5\)? OK" % path self.expected_in(exp, result) exp = "hashnot failed: no valid checksum found" self.expected_in(exp, result) except hpss.HSIerror as e: if MSG.hpss_unavailable in str(e): pytest.skip(str(e))
def test_hashverify_ok_list(self): """ Issue "hashverify" in hsi, return results """ self.dbgfunc() try: plist = self.plist + ["%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 "\(?none\)? %s" % path in x: h.hashcreate(path) # run hashverify on the list result = h.hashverify(plist) h.quit() # verify the results: we should see "OK" for the hashables and an # error for hashnot self.expected_in("hashverify", result) for path in self.plist: self.expected_in("%s: \(?md5\)? OK" % path, result) self.expected_in("hashnot failed: no valid checksum found", result) except hpss.HSIerror as e: if MSG.hpss_unavailable in str(e): pytest.skip(str(e))
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))
def test_chdir_noarg(self): """ Change dir in HPSS to a non directory """ try: h = hpss.HSI(verbose=("verbose" in testhelp.testargs())) self.assertRaisesMsg(TypeError, "chdir() takes exactly 2 arguments", h.chdir) except hpss.HSIerror as e: if MSG.hpss_unavailable in str(e): pytest.skip(str(e))
def test_lsP_str(self): """ Issue "ls -P foo bar" in hic_test, validate results """ try: h = hpss.HSI(verbose=("verbose" in testhelp.testargs())) result = h.lsP(self.paths) for path in self.plist: self.expected_in("FILE\s+%s" % util.basename(path), result) except hpss.HSIerror as e: if MSG.hpss_unavailable in str(e): pytest.skip(str(e))
def test_chdir_unicode(self): """ Unicode argument to chdir should work """ try: h = hpss.HSI(verbose=("verbose" in testhelp.testargs())) ucdir = unicode("hic_test") result = h.chdir(ucdir) exp = "/home/tpb/hic_test" self.expected_in(exp, result) except hpss.HSIerror as e: if MSG.hpss_unavailable in str(e): pytest.skip(str(e))
def test_lsP_argnone(self): """ Issue "ls -P" in /home/tpb/hic_test with no arg, validate result """ try: h = hpss.HSI(verbose=("verbose" in testhelp.testargs())) h.chdir("/home/tpb/hic_test") result = h.lsP() for path in self.plist: self.expected_in("FILE\s+%s" % util.basename(path), result) except hpss.HSIerror as e: if MSG.hpss_unavailable in str(e): pytest.skip(str(e))
def test_hashlist_argnone(self): """ If hashlist gets no argument, it should throw an exception """ try: h = hpss.HSI(verbose=("verbose" in testhelp.testargs())) self.assertRaisesMsg(TypeError, "hashlist() takes exactly 2 arguments", h.hashlist) h.quit() except hpss.HSIerror as e: if MSG.hpss_unavailable in str(e): pytest.skip(str(e))
def test_hashverify_argnone(self): """ Issue "hashverify" in hsi, return results """ try: h = hpss.HSI(verbose=("verbose" in testhelp.testargs())) self.assertRaisesMsg(TypeError, "hashverify() takes exactly 2 arguments", h.hashverify) h.quit() except hpss.HSIerror as e: if MSG.hpss_unavailable in str(e): pytest.skip(str(e))
def test_lsP_argbad(self): """ Issue "ls -P" with non-string, non-list arg, expect exception """ try: h = hpss.HSI(verbose=("verbose" in testhelp.testargs())) self.assertRaisesMsg(hpss.HSIerror, "lsP: Invalid argument", h.lsP, 19) h.quit() except hpss.HSIerror as e: if MSG.hpss_unavailable in str(e): pytest.skip(str(e))
def test_chdir_ok(self): """ Successful change dir in HPSS """ self.dbgfunc() try: h = hpss.HSI(verbose=("verbose" in testhelp.testargs())) result = h.chdir("hic_test") h.quit() exp = "/home/tpb/hic_test" self.expected_in(exp, result) except hpss.HSIerror as e: if MSG.hpss_unavailable in str(e): pytest.skip(str(e))
def test_hashverify_argbad(self): """ If hashverify gets an invalid argument (not a str or list), it should throw an exception """ try: h = hpss.HSI(verbose=("verbose" in testhelp.testargs())) self.assertRaisesMsg(hpss.HSIerror, "hashverify: Invalid argument", h.hashverify, 32) h.quit() except hpss.HSIerror as e: if MSG.hpss_unavailable in str(e): pytest.skip(str(e))
def test_hashcreate_ok_str(self): """ Issue "hashcreate" in hsi with a string argument, return results """ try: h = hpss.HSI(verbose=("verbose" in testhelp.testargs())) result = h.hashcreate(self.paths) h.quit() self.expected_in("hashcreate", result) for path in self.paths.split(): exp = "\(?md5\)? %s" % path self.expected_in(exp, result) except hpss.HSIerror as e: if MSG.hpss_unavailable in str(e): pytest.skip(str(e))
def test_lscos(self): """ Issue "lscos", check result """ try: h = hpss.HSI(verbose=("verbose" in testhelp.testargs())) result = h.lscos() h.quit() self.expected_in("3003 Disk Big Backups", result) self.expected_in("5081 Disk X-Small", result) self.expected_in("6001 Disk Small", result) self.expected_in("6054 Disk Large_T", result) self.expected_in("6057 Disk X-Large_T 2-Copy", result) except hpss.HSIerror as e: if MSG.hpss_unavailable in str(e): pytest.skip(str(e))
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))
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))
def test_hashverify_ok_unicode(self): """ Issue "hashverify" in hsi with a unicode arg, return results """ self.dbgfunc() try: paths = unicode(self.paths + " %s/hashnot" % self.hdir) h = hpss.HSI(verbose=("verbose" in testhelp.testargs())) result = h.hashverify(paths) h.quit() self.expected_in("hashverify", result) for path in self.plist: self.expected_in("%s: \(?md5\)? OK" % path, result) self.expected_in("hashnot failed: no valid checksum found", result) except hpss.HSIerror as e: if MSG.hpss_unavailable in str(e): pytest.skip(str(e))