<commit_before>import pytest


class TestOnlyTask:
    """
    Test --task option
    """

    config = """
        tasks:
          test:
            mock:
              - {title: 'download', url: 'http://localhost/download'}
          test2:
            mock:
              - {title: 'nodownload', url: 'http://localhost/nodownload'}
    """

    @pytest.mark.skip(reason="1.2 we need to test this with execute command")
    def test_manual_with_onlytask(self, execute_task):
        # TODO: 1.2 we need to test this with execute command
        # Pretend we have been run with --task test
        # This task should run normally, as we specified it as onlytask
        task = execute_task('test', options=dict(tasks=['test']))
        assert task.find_entry(title='download'), 'task failed to download with --task'
        # This task should be disabled, as it wasn't specified with onlytask
        task = execute_task('test2', options=dict(tasks=['test']), abort_ok=True)
        assert task.aborted
        assert not task.find_entry(title='nodownload'), 'task should not have been executed'


class TestManualAutomatic:
    """
    Test manual download tasks
    """

    config = """
        tasks:
          test:
            manual: true
            mock:
              - {title: 'nodownload', url: 'http://localhost/nodownload'}
    """

    def test_manual_without_onlytask(self, execute_task):
        task = execute_task('test', abort=True)
        assert task.aborted
        assert not task.find_entry(title='nodownload'), 'Manual tasks downloaded on automatic run'


class TestManualOnlytask:
    """
    Test manual download tasks
    """

    config = """
        tasks:
          test2:
            manual: true
            mock:
              - {title: 'download', url: 'http://localhost/download'}
    """

    def test_manual_with_onlytask(self, execute_task):
        # Pretend we have been run with --task test2
        task = execute_task('test2', options=dict(tasks=['test2'], allow_manual=True))
        assert task.find_entry(title='download'), 'Manual tasks failed to download on manual run'<commit_msg>Add a test for #3331<commit_after>import pytest


class TestOnlyTask:
    """
    Test --task option
    """

    config = """
        tasks:
          test:
            mock:
              - {title: 'download', url: 'http://localhost/download'}
          test2:
            mock:
              - {title: 'nodownload', url: 'http://localhost/nodownload'}
    """

    @pytest.mark.skip(reason="1.2 we need to test this with execute command")
    def test_manual_with_onlytask(self, execute_task):
        # TODO: 1.2 we need to test this with execute command
        # Pretend we have been run with --task test
        # This task should run normally, as we specified it as onlytask
        task = execute_task('test', options=dict(tasks=['test']))
        assert task.find_entry(title='download'), 'task failed to download with --task'
        # This task should be disabled, as it wasn't specified with onlytask
        task = execute_task('test2', options=dict(tasks=['test']), abort_ok=True)
        assert task.aborted
        assert not task.find_entry(title='nodownload'), 'task should not have been executed'


class TestManualAutomatic:
    """
    Test manual download tasks
    """

    config = """
        tasks:
          test:
            manual: true
            mock:
              - {title: 'nodownload', url: 'http://localhost/nodownload'}
    """

    def test_manual_without_onlytask(self, execute_task):
        task = execute_task('test', abort=True)
        assert task.aborted
        assert not task.find_entry(title='nodownload'), 'Manual tasks downloaded on automatic run'

    def test_manual_with_startasks(self, execute_task):
        """
        Specifying just '*' as the tasks option should be considered
        the same as not specifying any specific tasks.
        """
        execute_task
        task = execute_task('test', abort=True, options={'tasks': ['*'], 'allow_manual': True})
        assert task.aborted
        assert not task.find_entry(title='nodownload'), 'Manual tasks downloaded on automatic run'


class TestManualOnlytask:
    """
    Test manual download tasks
    """

    config = """
        tasks:
          test2:
            manual: true
            mock:
              - {title: 'download', url: 'http://localhost/download'}
    """

    def test_manual_with_onlytask(self, execute_task):
        # Pretend we have been run with --task test2
        task = execute_task('test2', options=dict(tasks=['test2'], allow_manual=True))
        assert task.find_entry(title='download'), 'Manual tasks failed to download on manual run'
{'fraction_non_alphanumeric': 0.11351122405760271, 'fraction_numerical': 0.005082592121982211, 'mean_word_length': 2.402737752161383, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 36, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6419007', 'n_tokens_mistral': 1330, 'n_tokens_neox': 1289, 'n_words': 387}