예제 #1
0
    def test_create_path_one_file(self):
        file = tempfile.NamedTemporaryFile(dir=self.d, delete=False)

        actual = pathinby.create_path(self.d, None, '|', '|-')
        expected = ['|-'+os.path.basename(file.name)]

        self.assertEqual(actual, expected)
예제 #2
0
    def test_output_file(self):
        file1 = tempfile.NamedTemporaryFile(dir=self.d, delete=False)
        file2 = tempfile.NamedTemporaryFile(dir=self.d, delete=False)
        outputFile = tempfile.NamedTemporaryFile(dir=self.d, delete=False)

        fileObject = open(outputFile.name, 'r+w')
        pathinby.create_path(self.d, fileObject, '|', '|-')

        with open(outputFile.name, 'r') as file:
            actual = collections.Counter(file.read())

        expected = collections.Counter(
                    '\n'.join(
                        ['|-'+os.path.basename(file1.name),
                         '|-'+os.path.basename(file2.name),
                         '|-'+os.path.basename(outputFile.name)
                         ]
                    )
                   )

        self.assertEqual(actual, expected)
예제 #3
0
    def test_create_path_multiple_files(self):
        file1 = tempfile.NamedTemporaryFile(dir=self.d, delete=False)
        file2 = tempfile.NamedTemporaryFile(dir=self.d, delete=False)

        actual = collections.Counter(pathinby.create_path(self.d, None, '|', '|-'))
        expected = collections.Counter(
                       ['|-'+os.path.basename(file1.name),
                        '|-'+os.path.basename(file2.name)
                        ]
                   )

        self.assertEqual(actual, expected)
예제 #4
0
    def test_create_path_empty_directory(self):
        actual = pathinby.create_path(self.d, None, '|', '|-')
        expected = []

        self.assertEqual(actual, expected)