Esempio n. 1
0
 def create_directory(self):
     ExampleDirSpiders.create_directory(self)
     # Add an absolute link
     self.add_link("absolute.txt",self.path("fly.txt"))
     # Add a broken absolute link
     self.add_link("absolutely_broken.txt",self.path("absolutely_missing.txt"))
     # Add a relative link with '..'
     self.add_link("web/relative.txt","../spider.txt")
     # Add a link to a directory
     self.add_link("web2","web")
Esempio n. 2
0
 def create_directory(self):
     ExampleDirSpiders.create_directory(self)
     # Add an absolute link
     self.add_link("absolute.txt",self.path("fly.txt"))
     # Add a broken absolute link
     self.add_link("absolutely_broken.txt",self.path("absolutely_missing.txt"))
     # Add a relative link with '..'
     self.add_link("web/relative.txt","../spider.txt")
     # Add a link to a directory
     self.add_link("web2","web")
     # Add a link to a link
     self.add_link("web/related.txt","relative.txt")
     # Add a file that will appear in the linked directory
     self.add_file("web/parlour.txt","I have a little something here")
Esempio n. 3
0
 def __init__(self):
     ExampleDirSpiders.__init__(self)
Esempio n. 4
0
 def setUp(self):
     """Build directory with test data
     """
     self.example_dir = ExampleDirSpiders()
     self.wd = self.example_dir.create_directory()
Esempio n. 5
0
class TestMd5CheckerMd5cmpFiles(unittest.TestCase):
    """Tests for the 'md5cmp_files' method of the Md5Checker class

    """
    def setUp(self):
        """Build directory with test data
        """
        self.example_dir = ExampleDirSpiders()
        self.wd = self.example_dir.create_directory()

    def tearDown(self):
        """Remove directory with test data
        """
        self.example_dir.delete_directory()

    def test_cmp_identical_files(self):
        """Md5Checker.md5cmp_files compare identical files
        """
        self.assertEqual(Md5Checker.MD5_OK,
                         Md5Checker.md5cmp_files(self.example_dir.path('spider.txt'),
                                                 self.example_dir.path('spider2.txt')))
        self.assertEqual(Md5Checker.MD5_OK,
                         Md5Checker.md5cmp_files(self.example_dir.path('spider2.txt'),
                                                 self.example_dir.path('spider.txt')))

    def test_cmp_different_files(self):
        """Md5Checker.md5cmp_files compare different files
        """
        self.assertEqual(Md5Checker.MD5_FAILED,
                         Md5Checker.md5cmp_files(self.example_dir.path('spider.txt'),
                                                 self.example_dir.path('fly.txt')))
        self.assertEqual(Md5Checker.MD5_FAILED,
                         Md5Checker.md5cmp_files(self.example_dir.path('fly.txt'),
                                                 self.example_dir.path('spider.txt')))

    def test_cmp_missing_reference(self):
        """Md5Checker.md5cmp_files with missing reference file
        """
        self.assertEqual(Md5Checker.MD5_ERROR,
                         Md5Checker.md5cmp_files(self.example_dir.path('missing.txt'),
                                                 self.example_dir.path('spider.txt')))

    def test_cmp_missing_target(self):
        """Md5Checker.md5cmp_files with missing target file
        """
        self.assertEqual(Md5Checker.MD5_ERROR,
                         Md5Checker.md5cmp_files(self.example_dir.path('spider.txt'),
                                                 self.example_dir.path('missing.txt')))

    def test_cmp_file_and_link(self):
        """Md5Checker.md5cmp_files with a file against a symlink
        """
        self.assertEqual(Md5Checker.MD5_OK,
                         Md5Checker.md5cmp_files(self.example_dir.path('spider.txt'),
                                                 self.example_dir.path('itsy-bitsy.txt')))
        self.assertEqual(Md5Checker.MD5_OK,
                         Md5Checker.md5cmp_files(self.example_dir.path('itsy-bitsy.txt'),
                                                 self.example_dir.path('spider.txt')))
        self.assertEqual(Md5Checker.MD5_FAILED,
                         Md5Checker.md5cmp_files(self.example_dir.path('fly.txt'),
                                                 self.example_dir.path('itsy-bitsy.txt')))
        self.assertEqual(Md5Checker.MD5_FAILED,
                         Md5Checker.md5cmp_files(self.example_dir.path('itsy-bitsy.txt'),
                                                 self.example_dir.path('fly.txt')))

    def test_cmp_identical_links(self):
        """Md5Checker.md5cmp_files with symlinks pointing to identical files
        """
        self.assertEqual(Md5Checker.MD5_OK,
                         Md5Checker.md5cmp_files(self.example_dir.path('itsy-bitsy.txt'),
                                                 self.example_dir.path('itsy-bitsy2.txt')))
        self.assertEqual(Md5Checker.MD5_OK,
                         Md5Checker.md5cmp_files(self.example_dir.path('itsy-bitsy2.txt'),
                                                 self.example_dir.path('itsy-bitsy.txt')))

    def test_cmp_broken_link(self):
        """Md5Checker.md5cmp_files with a broken symlink
        """
        self.assertEqual(Md5Checker.MD5_ERROR,
                         Md5Checker.md5cmp_files(self.example_dir.path('spider.txt'),
                                                 self.example_dir.path('broken.txt')))
        self.assertEqual(Md5Checker.MD5_ERROR,
                         Md5Checker.md5cmp_files(self.example_dir.path('broken.txt'),
                                                 self.example_dir.path('spider.txt')))        

    def test_cmp_identical_broken_links(self):
        """Md5Checker.md5cmp_files with identical broken links
        """
        self.assertEqual(Md5Checker.MD5_ERROR,
                         Md5Checker.md5cmp_files(self.example_dir.path('broken.txt'),
                                                 self.example_dir.path('broken2.txt')))
        self.assertEqual(Md5Checker.MD5_ERROR,
                         Md5Checker.md5cmp_files(self.example_dir.path('broken2.txt'),
                                                 self.example_dir.path('broken.txt')))        

    def test_cmp_file_and_directory(self):
        """Md5Checker.md5cmp_files when one 'file' is a directory
        """
        self.assertEqual(Md5Checker.MD5_ERROR,
                         Md5Checker.md5cmp_files(self.example_dir.path('spider.txt'),
                                                 self.example_dir.dirn))
        self.assertEqual(Md5Checker.MD5_ERROR,
                         Md5Checker.md5cmp_files(self.example_dir.dirn,
                                                 self.example_dir.path('spider.txt')))