def test_normal_scan(self):
     # Check normal scan a path
     # Should return a list as expected
     expected = sorted(
         [os.path.join(os.getcwd(), out) for out in self.duplicate_files])
     result = sorted(fdf.scan_files(self.DIR_NAME))
     self.assertListEqual(result, expected)
 def test_symlink_not_in_result(self):
     # Check symlink not in result list
     # result should just contain only on file without any symlinks
     result = fdf.scan_files('./TEST_DIR/symlink_test')
     expected = [
         os.path.join(os.getcwd(), 'TEST_DIR/symlink_test/test_file1')
     ]
     self.assertEqual(result, expected)
 def setUp(self):
     # Setup the environment
     self.DIR_NAME = 'this_is_test_directory_name'
     process = Popen([
         './generate_duplicate_files.py', '--file-count', '5',
         '--duplicate-file-ratio', '1', '-p', self.DIR_NAME
     ],
                     stdout=PIPE)
     obj = process.communicate()[0].decode()
     obj = json.loads(obj)
     self.duplicate_files = [os.path.realpath(out[0]) for out in obj]
     self.LIST_OF_FILES = fdf.scan_files('.')
 def test_scan_non_exist_path(self):
     # Check scan a non-exist path
     # Should return an empty list
     result = fdf.scan_files('./TEST_DIR/non_exist_path')
     expected = []
     self.assertEqual(result, expected)
 def test_file_instead_dir(self):
     # Check scan a file instead of directory
     # Should return an empty list
     result = fdf.scan_files('./TEST_DIR/test_file')
     expected = []
     self.assertEqual(result, expected)
 def test_empty_dir(self):
     # Check scan an empty directory
     # Should return an empty list
     result = fdf.scan_files('./TEST_DIR/empty_dir')
     expected = []
     self.assertEqual(result, expected)