def test_process_snapshot(self): """Test the conversion of a snapshot into HTML.""" tail = TestLinkedList(name='tail') head = TestLinkedList(name='head', next_elem=tail) snapshot = JsonSnapshot() snapshot.make_entity_for_object(head) json_snapshot = snapshot.to_json_object() entity_manager = ProcessedEntityManager() processor = ProcessToRenderInfo( HtmlDocumentManager('test_json'), entity_manager) processor.max_uncollapsable_json_lines = 20 processor.max_uncollapsable_metadata_rows = 20 processor.max_uncollapsable_entity_rows = 20 processor.default_force_top_level_collapse = False in_relation = None entity_manager.push_entity_map(json_snapshot['_entities']) html_info = processor.process_entity_id(json_snapshot['_subject_id'], json_snapshot, in_relation) entity_manager.pop_entity_map(json_snapshot['_entities']) expect = """<table> <tr> <th><i>metadata</i></th> <td> <table> <tr><th>_id</th><td>1</td></tr> <tr><th>class</th><td>type TestLinkedList</td></tr> <tr><th>name</th><td>head</td></tr> </table> </td> </tr> <tr> <th>Next</th> <td> <table> <tr> <th><i>metadata</i></th> <td> <table> <tr><th>_id</th><td>2</td></tr> <tr><th>class</th><td>type TestLinkedList</td></tr> <tr><th>name</th><td>tail</td></tr> </table> </td> </tr> </table> </td> </tr> </table> """ # Test without regard to whitespace formatting. self.assertEquals(''.join(expect.split()), ''.join(str(html_info.detail_block).split()))
def test_process_snapshot(self): """Test the conversion of a snapshot into HTML.""" tail = TestLinkedList(name='tail') head = TestLinkedList(name='head', next_elem=tail) snapshot = JsonSnapshot() snapshot.make_entity_for_object(head) json_snapshot = snapshot.to_json_object() entity_manager = ProcessedEntityManager() processor = ProcessToRenderInfo(HtmlDocumentManager('test_json'), entity_manager) processor.max_uncollapsable_json_lines = 20 processor.max_uncollapsable_metadata_rows = 20 processor.max_uncollapsable_entity_rows = 20 processor.default_force_top_level_collapse = False in_relation = None entity_manager.push_entity_map(json_snapshot['_entities']) html_info = processor.process_entity_id(json_snapshot['_subject_id'], json_snapshot, in_relation) entity_manager.pop_entity_map(json_snapshot['_entities']) expect = """<table> <tr> <th><i>metadata</i></th> <td> <table> <tr><th>_id</th><td>1</td></tr> <tr><th>class</th><td>type TestLinkedList</td></tr> <tr><th>name</th><td>head</td></tr> </table> </td> </tr> <tr> <th>Next</th> <td> <table> <tr> <th><i>metadata</i></th> <td> <table> <tr><th>_id</th><td>2</td></tr> <tr><th>class</th><td>type TestLinkedList</td></tr> <tr><th>name</th><td>tail</td></tr> </table> </td> </tr> </table> </td> </tr> </table> """ # Test without regard to whitespace formatting. self.assertEquals(''.join(expect.split()), ''.join(str(html_info.detail_block).split()))