<commit_before>import pytest
from mixer.backend.django import mixer
from contentcuration import models as cc
from kolibri.content import models as k
from django.core.management import call_command
from django.test.utils import override_settings


@pytest.fixture
def channel():
    ext = mixer.blend('contentcuration.FileFormat', extension='mp4', mimetype='application/video')

    topic = mixer.blend('contentcuration.ContentKind', kind='topic')
    video = mixer.blend('contentcuration.ContentKind', kind='video')

    videopreset = mixer.blend('contentcuration.FormatPreset', id='mp4', kind=video)

    with cc.ContentNode.objects.delay_mptt_updates():
        root = mixer.blend('contentcuration.ContentNode', title="root", parent=None, kind=topic)
        level1 = mixer.blend('contentcuration.ContentNode', parent=root, kind=topic)
        level2 = mixer.blend('contentcuration.ContentNode', parent=level1, kind=topic)
        leaf = mixer.blend('contentcuration.ContentNode', parent=level2, kind=video)

    fileobj = mixer.blend('contentcuration.File', contentnode=leaf, file_format=ext, preset=videopreset)

    channel = mixer.blend('contentcuration.Channel', main_tree=root, name='testchannel')

    return channel


@pytest.mark.django_db
def test_things_work(channel, settings):
    # TODO (aron): split different gets/asserts into their own tests
    call_command('exportchannel', channel.name)<commit_msg>Break up the pytest fixtures.<commit_after>import pytest
from mixer.backend.django import mixer
from contentcuration import models as cc
from kolibri.content import models as k
from django.core.management import call_command


@pytest.fixture
def video():
    return mixer.blend('contentcuration.ContentKind', kind='video')


@pytest.fixture
def preset_video(video):
    return mixer.blend('contentcuration.FormatPreset', id='mp4', kind=video)


@pytest.fixture
def topic():
    return mixer.blend('contentcuration.ContentKind', kind='topic')


@pytest.fixture
def fileformat_mp4():
    return mixer.blend('contentcuration.FileFormat', extension='mp4', mimetype='application/video')


@pytest.fixture
def channel(topic, video, preset_video, fileformat_mp4):
    with cc.ContentNode.objects.delay_mptt_updates():
        root = mixer.blend('contentcuration.ContentNode', title="root", parent=None, kind=topic)
        level1 = mixer.blend('contentcuration.ContentNode', parent=root, kind=topic)
        level2 = mixer.blend('contentcuration.ContentNode', parent=level1, kind=topic)
        leaf = mixer.blend('contentcuration.ContentNode', parent=level2, kind=video)

    fileobj = mixer.blend('contentcuration.File', contentnode=leaf, file_format=fileformat_mp4, preset=preset_video)

    channel = mixer.blend('contentcuration.Channel', main_tree=root, name='testchannel')

    return channel


@pytest.mark.django_db
def test_things_work(channel, settings):
    # TODO (aron): split different gets/asserts into their own tests
    call_command('exportchannel', channel.name)
{'fraction_non_alphanumeric': 0.11548731642189586, 'fraction_numerical': 0.005006675567423231, 'mean_word_length': 5.630530973451328, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2140336', 'n_tokens_mistral': 933, 'n_tokens_neox': 895, 'n_words': 190}