Esempio n. 1
0
    def test_wrong_folder(self):
        """
        Tests with wrong folder name.

        Files:
            /test/a
            /test/b
        Run:
            ls.py /test/wrong/
        Result:
            raise Exception
        """
        filenames = ['a', 'b']
        mock = Mock(filenames)

        with self.assertRaises(Exception):
            ListDirectory.folder_from(mock.wrong_folder())
Esempio n. 2
0
    def test_wrong_prefix(self):
        """
        Tests with wrong prefix filename.

        Files:
            /test/a
            /test/b
        Run:
            ls.py /test/c
        Result:

        """
        filenames = ['aa', 'ab', 'bb']
        mock = Mock(filenames, {'wrong_prefix'})

        command = ListDirectory(mock.args())
        result = list(command.files_list())
        expect = mock.result_list()

        self.assertCountEqual(expect, result)
Esempio n. 3
0
    def test_long_list_option(self):
        """
        Tests with long list option.

        Files:
            /test/a
            /test/b
        Run:
            ls.py -l /test/
        Result:
            -rw-rw-r--  2020-02-01 18:47:00 a
            -rwxr-xr-x  2020-02-01 19:18:06 b
        """
        filenames = ['a', 'b']
        mock = Mock(filenames, {'long_list'})

        command = ListDirectory(mock.args())
        result = list(command.files_list())
        expect = mock.result_list()

        self.assertCountEqual(expect, result)
Esempio n. 4
0
    def test_default(self):
        """
        Tests default command.

        Files:
            /test/a
            /test/b
        Run:
            ls.py /test/
        Result:
            a
            b
        """
        filenames = ['a', 'b']
        mock = Mock(filenames)

        command = ListDirectory(mock.args())
        result = list(command.files_list())
        expect = mock.result_list()

        self.assertCountEqual(expect, result)
Esempio n. 5
0
    def test_hidden_files(self):
        """
        Tests with hidden files.

        Files:
            /test/a
            /test/b
            /test/.c
        Run:
            ls.py /test/
        Result:
            a
            b
            .c
        """
        filenames = ['a', 'b', '.c']
        mock = Mock(filenames)

        command = ListDirectory(mock.args())
        result = list(command.files_list())
        expect = mock.result_list()

        self.assertCountEqual(expect, result)
Esempio n. 6
0
    def test_miss_folder(self):
        """
        Tests with folder name missing.

        Files:
            /test/a
            /test/b
        Run:
            cd /test/
            ls.py
        Result:
            a
            b
        """
        filenames = ['a', 'b']
        mock = Mock(filenames, {'miss_folder'})

        os.chdir(mock.folder)

        command = ListDirectory(mock.args())
        result = list(command.files_list())
        expect = mock.result_list()

        self.assertCountEqual(expect, result)