def test_markup(self, sxs_markup, get_template):
        get_template.return_value.render.return_value = '[html]'
        sxs_markup.return_value = '[sxs-html]'

        notices.markup({
            'cfr_part': '2222',
            'document_number': '888-2222',
            'section_by_section': [
                'child1',
                'child2',
                'child3'
            ]
        })
        self.assertEqual(3, sxs_markup.call_count)  # per child
        self.assertEqual('child1', sxs_markup.call_args_list[0][0][0])
        self.assertEqual('child2', sxs_markup.call_args_list[1][0][0])
        self.assertEqual('child3', sxs_markup.call_args_list[2][0][0])

        context = get_template.return_value.render.call_args[0][0]
        self.assertEqual('2222', context['cfr_part'])
        self.assertEqual('888-2222', context['document_number'])
        #   get the markup for children
        self.assertEqual([
            '[sxs-html]', '[sxs-html]', '[sxs-html]'],
            context['sxs_markup'])
示例#2
0
    def test_markup(self, sxs_markup, get_template):
        get_template.return_value.render.return_value = '[html]'
        sxs_markup.return_value = '[sxs-html]'

        notices.markup({
            'cfr_part': '2222',
            'document_number': '888-2222',
            'section_by_section': [
                'child1',
                'child2',
                'child3'
            ]
        })
        self.assertEqual(3, sxs_markup.call_count)  # per child
        self.assertEqual('child1', sxs_markup.call_args_list[0][0][0])
        self.assertEqual('child2', sxs_markup.call_args_list[1][0][0])
        self.assertEqual('child3', sxs_markup.call_args_list[2][0][0])

        context = get_template.return_value.render.call_args[0][0]
        self.assertEqual('2222', context['cfr_part'])
        self.assertEqual('888-2222', context['document_number'])
        #   get the markup for children
        self.assertEqual([
            '[sxs-html]', '[sxs-html]', '[sxs-html]'],
            context['sxs_markup'])
    def handle(self, *args, **options):
        part, version = self.get_regulation_version(**options)

        view = ChromeRegulationView()
        view.request = HttpRequest()
        view.request.method = 'GET'
        context = view.get_context_data(label_id=part, version=version)
        template = loader.get_template(ChromeRegulationView.template_name)
        markup = template.render(Context(context))

       # markup = builder.render_markup()

        self.write_file(settings.OFFLINE_OUTPUT_DIR + 'rege.html', markup)
        front_end_dir = settings.OFFLINE_OUTPUT_DIR + 'static'

        #   If any dir in the path is symlinked, don't replace it
        if not path.islink(front_end_dir):
            #   Otherwise, copy the static dir to the output
            if path.exists(front_end_dir):
                shutil.rmtree(front_end_dir)
            shutil.copytree('../regulations/static/', front_end_dir)

        if not path.exists(settings.OFFLINE_OUTPUT_DIR + 'notice'):
            mkdir(settings.OFFLINE_OUTPUT_DIR + 'notice')

        all_notices = generator.get_all_notices(options.get('regulation_part'))
        for notice in all_notices: #notices.fetch_all(api):
            self.write_file(settings.OFFLINE_OUTPUT_DIR + 'notice/' + 
                notice['document_number'] + ".html", notices.markup(notice))
示例#4
0
    def handle(self, *args, **options):
        part, version = self.get_regulation_version(**options)

        view = ChromeRegulationView()
        view.request = HttpRequest()
        view.request.method = 'GET'
        context = view.get_context_data(label_id=part, version=version)
        template = loader.get_template(ChromeRegulationView.template_name)
        markup = template.render(Context(context))

        # markup = builder.render_markup()

        self.write_file(settings.OFFLINE_OUTPUT_DIR + 'rege.html', markup)
        front_end_dir = settings.OFFLINE_OUTPUT_DIR + 'static'

        #   If any dir in the path is symlinked, don't replace it
        if not path.islink(front_end_dir):
            #   Otherwise, copy the static dir to the output
            if path.exists(front_end_dir):
                shutil.rmtree(front_end_dir)
            shutil.copytree('../regulations/static/', front_end_dir)

        if not path.exists(settings.OFFLINE_OUTPUT_DIR + 'notice'):
            mkdir(settings.OFFLINE_OUTPUT_DIR + 'notice')

        all_notices = generator.get_all_notices(options.get('regulation_part'))
        for notice in all_notices:  #notices.fetch_all(api):
            self.write_file(
                settings.OFFLINE_OUTPUT_DIR + 'notice/' +
                notice['document_number'] + ".html", notices.markup(notice))