Exemplo n.º 1
0
    def test__collect_with_file(self):
        """
        Should call _collect_single
        :return:
        """
        from artefact.localhost.file import FileCopy

        expected_source = "./testtree/testfile1"
        collector = FileCopy(parameters={}, parent=None)
        with mock.patch.object(collector, '_collect_single') as mock_:
            collector._source_path = expected_source
            collector._collect()
            mock_.assert_called_once()
Exemplo n.º 2
0
    def test__collect_with_two_files(self):
        """
        Should call _collect_single two times.
        :return:
        """
        from artefact.localhost.file import FileCopy

        collector = FileCopy(parameters={}, parent=None)
        expected_file_path = f"./testtree/testfile1{FileCopy._FILE_PATH_SEPERATOR}./testtree/testfile2"
        collector.source_path = expected_file_path

        expected_call_count = 2
        single_mock: MagicMock = MagicMock()
        with mock.patch('artefact.localhost.file.FileCopy._collect_single',
                        single_mock):
            collector._collect()

        self.assertEqual(expected_call_count, single_mock.call_count)