From dd92cb44d95b307a7d2a2a5011e65a7da9a06bb6 Mon Sep 17 00:00:00 2001 From: Maximilien Rigaut Date: Mon, 16 May 2022 04:07:26 +0200 Subject: [PATCH] Full coverage, bugsquashing next --- tests/modules/test_export.py | 73 +++++++++++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) diff --git a/tests/modules/test_export.py b/tests/modules/test_export.py index 3731774..9098859 100644 --- a/tests/modules/test_export.py +++ b/tests/modules/test_export.py @@ -1,5 +1,76 @@ import bootstraparse.modules.export as export +import pytest def test_export(): - assert export + """ + Test the export module + """ + em = export.ExportManager("test", "test") + assert type(em) is export.ExportManager + + +def test_export_request(): + """ + Test the export_request named_tuple + """ + export_test = export.ExportRequest("type", "subtype", "optionals", "others") + assert export_test.type == "type" + assert export_test.subtype == "subtype" + assert export_test.optionals == "optionals" + assert export_test.others == "others" + + +def test_export_responcse(): + """ + Test the export_response named_tuple + """ + export_test = export.ExportResponse("start", "end") + assert export_test.start == "start" + assert export_test.end == "end" + + +@pytest.mark.parametrize("export_type, export_subtype", [ + ("structural_elements", "header"), + ("structural_elements", "display"), + ("inline_elements", "link"), + ("table", "t_head"), + ("table", "t_row"), + ("table", "t_cell"), + ("structural_elements", "div"), +]) +def test_transform(export_type, export_subtype): + """ + Test the transform method + """ + em = export.ExportManager("test", "test") + re = em.transform(export.ExportRequest(export_type, export_subtype, "", { + "header_level": "1", + "display_level": "1", + "col_span": "1", + "row_span": "1", + "url": "1" + })) + re2 = em(export.ExportRequest(export_type, export_subtype, "", { + "header_level": "1", + "display_level": "1", + "col_span": "1", + "row_span": "1", + "url": "1" + })) + assert type(re) is export.ExportResponse + + +def test_get_template_error(): + with pytest.raises(SystemExit): + em = export.ExportManager("test", "test") + em(export.ExportRequest("nope", "header", "", {})) + + +def test_with_optionnals(): + em = export.ExportManager("test", "test") + em(export.ExportRequest("structural_elements", "div", "boo")) + + +def test_return_values(): + pass