Example #1
0
def transform_section(sane_section: dict):
    section = sane_to_section(sane_section)

    if section.type == 'markdown':
        section.contents = markdown_to_section_list(section.contents)

    return section
Example #2
0
def test_sane_to_section_markdown():
    json = get_mock('elements/markdown.json')

    section = sane_to_section(json[0])
    assert isinstance(section, Section)
    assert section.type == 'markdown'
    assert isinstance(section.contents, str)
    assert all([
        i in section.layout for i in [
            ROW_POSITION_KEY, COL_POSITION_KEY, HEIGHT_POSITION_KEY,
            WIDTH_POSITION_KEY
        ]
    ])
Example #3
0
def test_sane_to_section_quote():
    # TODO: make sure that quote contents has a list
    json = get_mock('elements/quote.json')

    section = sane_to_section(json[0])
    assert isinstance(section, Section)
    assert section.type == 'markdown'
    assert isinstance(section.contents, str)
    assert all([
        i in section.layout for i in [
            ROW_POSITION_KEY, COL_POSITION_KEY, HEIGHT_POSITION_KEY,
            WIDTH_POSITION_KEY
        ]
    ])
Example #4
0
def test_sane_to_section_table():
    json = get_mock('elements/table.json')

    section = sane_to_section(json[0])
    assert isinstance(section, Section)
    assert section.type == 'table'
    assert isinstance(section.contents, list)
    assert isinstance(section.contents[0], dict)
    assert all([
        i in section.layout for i in [
            ROW_POSITION_KEY, COL_POSITION_KEY, HEIGHT_POSITION_KEY,
            WIDTH_POSITION_KEY
        ]
    ])
Example #5
0
def test_sane_to_section_number_trend():
    json = get_mock('elements/number_and_trend.json')

    section = sane_to_section(json[0])
    assert isinstance(section, Section)
    assert section.type == 'number'
    assert isinstance(section.contents, int)
    assert all([
        i in section.layout for i in [
            ROW_POSITION_KEY, COL_POSITION_KEY, HEIGHT_POSITION_KEY,
            WIDTH_POSITION_KEY
        ]
    ])

    section = sane_to_section(json[1])
    assert isinstance(section, Section)
    assert section.type == 'trend'
    assert isinstance(section.contents, dict)
    assert all([
        i in section.layout for i in [
            ROW_POSITION_KEY, COL_POSITION_KEY, HEIGHT_POSITION_KEY,
            WIDTH_POSITION_KEY
        ]
    ])