def test_process_node_appliers(self): node = { "text": "Text text text.", "children": [], "label": ["123", "aaa"], 'node_type': REGTEXT } inline = Mock() inline.get_layer_pairs.return_value = [] par = Mock() par.apply_layers.return_value = node sr = Mock() sr.get_layer_pairs.return_value = [] builder = HTMLBuilder(inline, par, sr) builder.process_node(node) self.assertTrue(inline.get_layer_pairs.called) self.assertEqual("123-aaa", inline.get_layer_pairs.call_args[0][0]) self.assertEqual("Text text text.", inline.get_layer_pairs.call_args[0][1]) self.assertTrue(par.apply_layers.called) self.assertEqual(node, par.apply_layers.call_args[0][0])
def test_interp_node_with_citations(self): inline, p, sr = Mock(), Mock(), Mock() builder = HTMLBuilder(inline, p, sr) node = { 'text': 'Interpretation with a link', 'children': [], 'node_type': INTERP, 'label': ['999', '5', 'Interp'] } p.apply_layers.return_value = node inline.get_layer_pairs.return_value = [] sr.get_layer_pairs.return_value = [] builder.process_node(node) layer_parameters = inline.get_layer_pairs.call_args[0] self.assertEqual('Interpretation with a link', layer_parameters[1]) self.assertEqual('999-5-Interp', layer_parameters[0])
def test_process_node_header(self): builder = HTMLBuilder(None, ParagraphLayersApplier(), None) node = { 'text': '', 'children': [], 'label': ['99', '22'], 'node_type': REGTEXT } builder.process_node(node) self.assertFalse('header' in node) node = { 'text': '', 'children': [], 'label': ['99', '22'], 'title': 'Some Title', 'node_type': REGTEXT } builder.process_node(node) self.assertTrue('header' in node) self.assertEqual('Some Title', node['header']) node = { 'text': '', 'children': [], 'label': ['99', '22'], 'title': u'§ 22.1 Title', 'node_type': REGTEXT } builder.process_node(node) self.assertTrue('header' in node)