Exemplo n.º 1
0
def example_header_logo(out_file_name='example.docx'):
    main.run(get_mock('grid_checks/fullgrid.json', ret_dict=False),
             out_file_name,
             options={
                 'customerLogo': XSOAR_LOGO_BASE64,
                 'demistoLogo': XSOAR_LOGO_BASE64
             })
Exemplo n.º 2
0
def test_pages_grid_constructor():
    sane_json = SaneJson(get_mock('basic.json'))
    assert len(sane_json.sane_pages) == 1

    first_page = sane_json.sane_pages[0]
    assert isinstance(first_page, SaneJsonPage)
    assert len(first_page) == 2
Exemplo n.º 3
0
def test_calculate_page_grid_empty():
    sane_json = SaneJson(get_mock('grid_checks/onecellgrid.json'))
    page = sane_json.get_sane_page(0)
    if SHOULD_HAVE_12_GRID:
        assert page.calculate_page_grid() == (12, 1)
    else:
        assert page.calculate_page_grid() == (1, 1)
Exemplo n.º 4
0
def test_sane_json_constructor():
    sane_json = SaneJson(get_mock('basic.json'))

    assert sane_json
    assert len(sane_json.json_data) == 2
    assert sane_json.json_data[0]['type'] == 'text'
    assert sane_json.json_data[1]['type'] == 'text'
Exemplo n.º 5
0
def test_normalize_row_positions():
    sane_json = SaneJson(get_mock('grid_checks/fullgridpaged.json'))

    for sane_page in sane_json.get_sane_pages():
        sections = sane_page.get_sections()

        # Let's test that the page starts with 0
        assert sorted([row_pos(s) for s in sections])[0] == 0
Exemplo n.º 6
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
        ]
    ])
Exemplo n.º 7
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
        ]
    ])
Exemplo n.º 8
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
        ]
    ])
Exemplo n.º 9
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
        ]
    ])
Exemplo n.º 10
0
def example_old_json(out_file_name='example.docx'):
    main.run(get_mock('old_json.json', ret_dict=False), out_file_name)
Exemplo n.º 11
0
def example_hr(out_file_name='example.docx'):
    main.run(get_mock('elements/hr.json', ret_dict=False), out_file_name)
Exemplo n.º 12
0
def example_markdown_paged(out_file_name='example.docx'):
    main.run(get_mock('elements/markdown_paged2.json', ret_dict=False),
             out_file_name)
Exemplo n.º 13
0
def example_table_new(out_file_name='example.docx'):
    main.run(get_mock('elements/table_new_json.json', ret_dict=False),
             out_file_name)
Exemplo n.º 14
0
def example():
    main.run(get_mock('example.json', ret_dict=False), 'example.docx')
Exemplo n.º 15
0
def example_orientation_landscape(out_file_name='example.docx'):
    main.run(get_mock('grid_checks/fullgrid.json', ret_dict=False),
             out_file_name, {'orientation': 'landscape'})
Exemplo n.º 16
0
def example_duration(out_file_name='example.docx'):
    main.run(get_mock('elements/duration.json', ret_dict=False), out_file_name)
Exemplo n.º 17
0
def test_calculate_page_grid():
    sane_json = SaneJson(get_mock('basic.json'))
    page = sane_json.get_sane_page(0)
    assert page.calculate_page_grid() == (12, 2)
Exemplo n.º 18
0
def example_image_svg(out_file_name='example.docx'):
    main.run(get_mock('elements/image-svg.json', ret_dict=False),
             out_file_name)
Exemplo n.º 19
0
def test_calculate_page_grid_merge():
    sane_json = SaneJson(get_mock('grid_checks/mergegrid.json'))
    page = sane_json.get_sane_page(0)
    assert page.calculate_page_grid() == (12, 9)
Exemplo n.º 20
0
def test_remove_first_logos_all_removal():
    json = get_mock('logo_removal3.json')
    assert len(remove_first_logos(json)) == 0
Exemplo n.º 21
0
def test_no_second_page_exception():
    sane_json = SaneJson(get_mock('basic.json'))
    with pytest.raises(IndexError):
        sane_json.get_sane_page(1)
Exemplo n.º 22
0
def _example_junk(out_file_name='example.docx'):
    # Generate a big elements file for testing
    main.run(get_mock('junkbig.json', ret_dict=False), out_file_name)
Exemplo n.º 23
0
def example_bar_chart(out_file_name='example.docx'):
    main.run(get_mock('elements/bar_chart.json', ret_dict=False),
             out_file_name)
Exemplo n.º 24
0
def test_sane_json_invalid_2ndpage_no_height_key():
    with pytest.raises(JsonSchemaException) as e:
        SaneJson(get_mock('invalid/bad_sane_json_7.json'))
    assert "data[1].layout must contain ['rowPos', 'columnPos', 'h', 'w']" + \
           " properties" in str(e.value)
Exemplo n.º 25
0
def example_unimplemented(out_file_name='example.docx'):
    main.run(get_mock('elements/unimplemented.json', ret_dict=False),
             out_file_name)
Exemplo n.º 26
0
def test_sane_json_invalid_layout_keys():
    with pytest.raises(JsonSchemaException) as e:
        SaneJson(get_mock('invalid/invalid_layout_keys.json'))
    assert 'data[0].layout.h must be bigger than or equal to 1' in str(e.value)
Exemplo n.º 27
0
def example_paper_size_a3(out_file_name='example.docx'):
    main.run(get_mock('grid_checks/fullgrid.json', ret_dict=False),
             out_file_name, {'paper_size': 'A3'})
Exemplo n.º 28
0
def example_number(out_file_name='example.docx'):
    main.run(get_mock('elements/number_and_trend.json', ret_dict=False),
             out_file_name)
Exemplo n.º 29
0
def example_paged(out_file_name='example.docx'):
    main.run(get_mock('grid_checks/fullgridpaged.json', ret_dict=False),
             out_file_name)
Exemplo n.º 30
0
def test_remove_first_logos_initial_logo():
    json = get_mock('logo_removal4.json')
    assert len(remove_first_logos(json)) == 3