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'])
Ejemplo n.º 2
0
    def __init__(self):
        self.appliers = {
            LayerBase.INLINE: InlineLayersApplier(),
            LayerBase.PARAGRAPH: ParagraphLayersApplier(),
            LayerBase.SEARCH_REPLACE: SearchReplaceLayersApplier()}

        self.api = api_reader.ApiReader()
Ejemplo n.º 3
0
    def test_modify_interp_node_header(self):
        node = {
            'children': [],
            'header': 'This interprets 22(a), a paragraph',
            'label': ['872', '22', 'a', 'Interp'],
            'node_type': INTERP,
        }
        icl = InternalCitationLayer(None)
        icl.sectional = True
        ila = InlineLayersApplier()
        ila.add_layer(icl)
        builder = CFRHTMLBuilder(ila, None, None)

        builder.modify_interp_node(node)
        self.assertEqual(
            'This interprets ' + icl.render_url(['872', '22', 'a'], '22(a)') +
            ', a paragraph', node['header_markup'])

        node['label'] = ['872', '22']
        builder.modify_interp_node(node)
        self.assertEqual(node['header'], node['header_markup'])
    def test_modify_interp_node_header(self):
        node = {
            'children': [],
            'header': 'This interprets 22(a), a paragraph',
            'label': ['872', '22', 'a', 'Interp'],
            'node_type': INTERP,
        }
        icl = InternalCitationLayer(None)
        icl.sectional = True
        ila = InlineLayersApplier()
        ila.add_layer(icl)
        builder = HTMLBuilder(ila, None, None)

        builder.modify_interp_node(node)
        self.assertEqual('This interprets '
                         + icl.render_url(['872', '22', 'a'], '22(a)')
                         + ', a paragraph', node['header_markup'])

        node['label'] = ['872', '22']
        builder.modify_interp_node(node)
        self.assertEqual(node['header'], node['header_markup'])
Ejemplo n.º 5
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)