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 })
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
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)
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'
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
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 ] ])
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 ] ])
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 ] ])
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 ] ])
def example_old_json(out_file_name='example.docx'): main.run(get_mock('old_json.json', ret_dict=False), out_file_name)
def example_hr(out_file_name='example.docx'): main.run(get_mock('elements/hr.json', ret_dict=False), out_file_name)
def example_markdown_paged(out_file_name='example.docx'): main.run(get_mock('elements/markdown_paged2.json', ret_dict=False), out_file_name)
def example_table_new(out_file_name='example.docx'): main.run(get_mock('elements/table_new_json.json', ret_dict=False), out_file_name)
def example(): main.run(get_mock('example.json', ret_dict=False), 'example.docx')
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'})
def example_duration(out_file_name='example.docx'): main.run(get_mock('elements/duration.json', ret_dict=False), out_file_name)
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)
def example_image_svg(out_file_name='example.docx'): main.run(get_mock('elements/image-svg.json', ret_dict=False), out_file_name)
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)
def test_remove_first_logos_all_removal(): json = get_mock('logo_removal3.json') assert len(remove_first_logos(json)) == 0
def test_no_second_page_exception(): sane_json = SaneJson(get_mock('basic.json')) with pytest.raises(IndexError): sane_json.get_sane_page(1)
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)
def example_bar_chart(out_file_name='example.docx'): main.run(get_mock('elements/bar_chart.json', ret_dict=False), out_file_name)
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)
def example_unimplemented(out_file_name='example.docx'): main.run(get_mock('elements/unimplemented.json', ret_dict=False), out_file_name)
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)
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'})
def example_number(out_file_name='example.docx'): main.run(get_mock('elements/number_and_trend.json', ret_dict=False), out_file_name)
def example_paged(out_file_name='example.docx'): main.run(get_mock('grid_checks/fullgridpaged.json', ret_dict=False), out_file_name)
def test_remove_first_logos_initial_logo(): json = get_mock('logo_removal4.json') assert len(remove_first_logos(json)) == 3