コード例 #1
0
    def test_get_context_data(self, generator):
        generator.get_tree_paragraph.return_value = {
            'text': 'Some Text',
            'children': [],
            'label': ['867', '53', 'q', 'Interp'],
            'node_type': INTERP
        }
        request = RequestFactory().get('/fake-path')
        view = partial_interp.PartialInterpView.as_view(
            appliers=(InlineLayersApplier(), ParagraphLayersApplier(),
                      SearchReplaceLayersApplier()))
        response = view(request, label_id='lablab', version='verver')
        self.assertEqual(response.context_data['c']['node_type'], INTERP)
        self.assertEqual(response.context_data['c']['children'],
                         [generator.get_tree_paragraph.return_value])
        self.assertFalse(response.context_data['inline'])

        view = partial_interp.PartialInterpView.as_view(
            inline=True,
            appliers=(InlineLayersApplier(), ParagraphLayersApplier(),
                      SearchReplaceLayersApplier()))
        response = view(request, label_id='lablab', version='verver')
        self.assertEqual(response.context_data['c']['node_type'], INTERP)
        self.assertEqual(response.context_data['c']['children'],
                         [generator.get_tree_paragraph.return_value])
        self.assertTrue(response.context_data['inline'])
コード例 #2
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)
コード例 #3
0
    def __init__(self):
        self.appliers = {
            LayerBase.INLINE: InlineLayersApplier(),
            LayerBase.PARAGRAPH: ParagraphLayersApplier(),
            LayerBase.SEARCH_REPLACE: SearchReplaceLayersApplier()}

        self.api = api_reader.ApiReader()
コード例 #4
0
 def test_generate_html(self):
     regulation_tree = {
         'text': '',
         'children': [],
         'label': ['8675'],
         'title': 'Regulation R',
         'node_type': REGTEXT
     }
     i_applier = InlineLayersApplier()
     p_applier = ParagraphLayersApplier()
     sr_applier = SearchReplaceLayersApplier()
     appliers = (i_applier, p_applier, sr_applier)
     builder = partial.generate_html(regulation_tree, appliers)
     self.assertEquals(builder.tree, regulation_tree)
     self.assertEquals(builder.inline_applier, i_applier)
     self.assertEquals(builder.p_applier, p_applier)
     self.assertEquals(builder.search_applier, sr_applier)