Exemplo n.º 1
0
def default_hearing(john_doe, contact_person):
    """
    Fixture for a "default" hearing with three sections (one main, two other sections).
    All objects will have the 3 default images attached.
    All objects will allow open commenting.
    """
    hearing = Hearing.objects.create(
        title='Default test hearing One',
        open_at=now() - datetime.timedelta(days=1),
        close_at=now() + datetime.timedelta(days=1),
        slug='default-hearing-slug'
    )
    for x in range(1, 4):
        section_type = (InitialSectionType.MAIN if x == 1 else InitialSectionType.SCENARIO)
        section = Section.objects.create(
            abstract='Section %d abstract' % x,
            hearing=hearing,
            type=SectionType.objects.get(identifier=section_type),
            commenting=Commenting.OPEN
        )
        create_default_images(section)
        section.comments.create(created_by=john_doe, content=default_comment_content[::-1])
        section.comments.create(created_by=john_doe, content=red_comment_content[::-1])
        section.comments.create(created_by=john_doe, content=green_comment_content[::-1])

    assert_ascending_sequence([s.ordering for s in hearing.sections.all()])

    hearing.contact_persons.add(contact_person)

    return hearing
Exemplo n.º 2
0
def default_hearing(john_doe, contact_person):
    """
    Fixture for a "default" hearing with three sections (one main, two other sections).
    All objects will have the 3 default images attached.
    All objects will allow open commenting.
    """
    hearing = Hearing.objects.create(
        title='Default test hearing One',
        open_at=now() - datetime.timedelta(days=1),
        close_at=now() + datetime.timedelta(days=1),
        slug='default-hearing-slug')
    for x in range(1, 4):
        section_type = (InitialSectionType.MAIN
                        if x == 1 else InitialSectionType.SCENARIO)
        section = Section.objects.create(
            abstract='Section %d abstract' % x,
            hearing=hearing,
            type=SectionType.objects.get(identifier=section_type),
            commenting=Commenting.OPEN)
        create_default_images(section)
        section.comments.create(created_by=john_doe,
                                content=default_comment_content[::-1])
        section.comments.create(created_by=john_doe,
                                content=red_comment_content[::-1])
        section.comments.create(created_by=john_doe,
                                content=green_comment_content[::-1])

    assert_ascending_sequence([s.ordering for s in hearing.sections.all()])

    hearing.contact_persons.add(contact_person)

    return hearing