def test_should_discover_source_files_when_scripts_are_included(self, discover_files_matching, _):
        project = Mock()

        project.get_property.return_value = True
        project.get_property.side_effect = lambda _property: _property

        discover_affected_files(False, True, project)

        discover_files_matching.assert_called_with('dir_source_main_scripts', '*')
    def test_should_discover_source_files_when_scripts_are_included(self, discover_files_matching, _):
        project = Mock()

        project.get_property.return_value = True
        project.get_property.side_effect = lambda _property: _property

        discover_affected_files(False, True, project)

        discover_files_matching.assert_called_with('dir_source_main_scripts', '*')
    def test_should_discover_source_files_when_test_sources_are_included(self, discover_python_files):
        project = Mock()

        project.get_property.side_effect = lambda _property: _property

        discover_affected_files(True, False, project)

        self.assertEqual(discover_python_files.call_args_list,
                         [call('dir_source_main_python'),
                          call('dir_source_unittest_python'),
                          call('dir_source_integrationtest_python')])
    def test_should_discover_source_files_when_test_sources_are_included(self, discover_python_files):
        project = Mock()

        project.get_property.side_effect = lambda _property: _property

        discover_affected_files(True, False, project)

        self.assertEqual(discover_python_files.call_args_list,
                         [call('dir_source_main_python'),
                          call('dir_source_unittest_python'),
                          call('dir_source_integrationtest_python')])
    def test_should_discover_source_files_when_test_sources_are_included_and_no_tests(self, discover_python_files):
        project = Mock()

        def get_property(property):
            if property == 'dir_source_main_python':
                return property
            return None
        project.get_property.side_effect = get_property

        discover_affected_files(True, project)

        self.assertEqual(discover_python_files.call_args_list,
                         [call('dir_source_main_python')])
    def test_should_discover_source_files_when_test_sources_are_included_and_no_tests(self, discover_python_files):
        project = Mock()

        def get_property(property):
            if property == 'dir_source_main_python':
                return property
            return None
        project.get_property.side_effect = get_property

        discover_affected_files(True, False, project)

        self.assertEqual(discover_python_files.call_args_list,
                         [call('dir_source_main_python')])
    def test_should_discover_source_files_when_test_sources_not_included(self, discover_python_files):
        project = Mock()
        project.get_property.return_value = 'source_directory'
        discover_python_files.return_value = ['foo.py', 'bar.py']

        files = discover_affected_files(False, False, project)
        discover_python_files.assert_called_with('source_directory')
        self.assertEqual(files, ['foo.py', 'bar.py'])
    def test_should_discover_source_files_when_test_sources_not_included(self, discover_python_files):
        project = Mock()
        project.get_property.return_value = 'source_directory'
        discover_python_files.return_value = ['foo.py', 'bar.py']

        files = discover_affected_files(False, False, project)
        discover_python_files.assert_called_with('source_directory')
        self.assertEqual(files, ['foo.py', 'bar.py'])