예제 #1
0
 def test_touch_oldpath_both(self):
     """
     Call touch on a path that does exist with both atime and mtime
     """
     self.dbgfunc()
     testpath = self.tmpdir(U.my_name())
     self.touch_payload(testpath, offs=(-175, -3423))
예제 #2
0
 def test_touch_oldpath_default(self):
     """
     Call touch on a path that does exist with no amtime tuple
     """
     self.dbgfunc()
     testpath = self.tmpdir(U.my_name())
     self.touch_payload(testpath, offs=())
예제 #3
0
 def test_touch_oldpath_mtime(self):
     """
     Call touch on a path that does exist with mtime, no atime
     """
     self.dbgfunc()
     testpath = self.tmpdir(U.my_name())
     self.touch_payload(testpath, offs=(None, -32))
예제 #4
0
 def test_touch_newpath_atime(self):
     """
     Call touch on a path that does not exist with atime, no mtime
     """
     self.dbgfunc()
     testpath = self.tmpdir(U.my_name())
     self.touch_payload(testpath, offs=(-75, None), new=True)
예제 #5
0
 def test_my_name(self):
     """
     Return the name of the calling function.
     """
     self.dbgfunc()
     actual = U.my_name()
     expected = 'test_my_name'
     self.expected(expected, actual)
예제 #6
0
    def test_touch_newpath_default(self):
        """
        Call touch on a path that does not exist with no amtime tuple

        This test code assumes that file system operations truncate atime and
        mtime rather than rounding them.
        """
        self.dbgfunc()
        testpath = self.tmpdir(U.my_name())
        self.touch_payload(testpath, offs=(), new=True)
예제 #7
0
    def test_date_start(self):
        """
        Given a file containing several log records (with some irrelevant
        introductory material), return the timestamp on the first one.
        """
        self.dbgfunc()
        tdata = [
            "This line should be ignored\n",
            "2014.0412 12:25:50 This is the timestamp to return\n",
            "2014.0430 19:30:00 This should not be returned\n"
        ]
        tfilename = self.tmpdir("%s.data" % (U.my_name()))
        f = open(tfilename, 'w')
        f.writelines(tdata)
        f.close()

        self.expected("2014.0412", U.date_start(tfilename))
예제 #8
0
    def test_rrfile_short(self):
        """
        Test the reverse read file class
        """
        self.dbgfunc()
        tdfile = self.tmpdir(U.my_name())
        clist = [chr(ord('a') + x) for x in range(0, 4)]
        with open(tdfile, 'w') as f:
            for c in clist:
                f.write(c * 16)

        rf = U.RRfile.open(tdfile, 'r')
        zlist = clist
        buf = rf.revread()
        self.expected(64, len(buf))
        for exp in ["aaa", "bbb", "ccc", "ddd"]:
            self.expected_in(exp, buf)

        rf.close()
예제 #9
0
    def test_date_end(self):
        """
        Given a file containing several log records, return the timestamp on
        the last one.
        """
        self.dbgfunc()
        tdata = [
            "This line should be ignored\n",
            "2014.0412 12:25:50 This is not the timestamp to return\n",
            "2014.0430 19:30:00 This should not be returned\n",
            "2014.0501 19:30:00 Return this one\n",
            "We want plenty of data here at the end of the file\n",
            "with no timestamp so we'll be forced to read\n",
            "backward a time or two, not just find the timestamp\n",
            "on the first read so we exercise revread.\n"
        ]
        tfilename = self.tmpdir("%s.data" % U.my_name())
        f = open(tfilename, 'w')
        f.writelines(tdata)
        f.close()

        self.expected("2014.0501", U.date_end(tfilename))
예제 #10
0
    def test_rrfile_long(self):
        """
        Test the reverse read file class
        """
        self.dbgfunc()
        tdfile = self.tmpdir(U.my_name())
        clist = [chr(ord('a') + x) for x in range(0, 16)]
        with open(tdfile, 'w') as f:
            for c in clist:
                f.write(c * 64)

        rf = U.RRfile.open(tdfile, 'r')
        zlist = clist
        buf = rf.revread()
        while buf != '':
            ref = zlist[-2:]
            del zlist[-1]
            self.expected(ref[0], buf[0])
            self.expected(ref[-1], buf[-1])
            buf = rf.revread()

        rf.close()