Esempio n. 1
0
def test_register_tab():
    class TestTab(object):
        type = 'test'
        pass

    tabs.register_tab(TestTab)
    with pytest.raises(ValueError):
        tabs.register_tab(TestTab)
    tabs.register_tab(TestTab, force=True)

    assert tabs.get_tab('test') is TestTab

    tabs.register_tab(TestTab, name='test-with-name')
    assert tabs.get_tab('test-with-name') is TestTab
Esempio n. 2
0
    def test_registry(self):
        # test get
        tab = tabs.get_tab('basic')
        self.assertIs(tab, tabs.Tab)
        tab = tabs.get_tab('\'plots\'')
        self.assertIs(tab, tabs.PlotTab)
        self.assertRaises(ValueError, tabs.get_tab, 'dfskaewf')

        # test register
        class TestTab(object):
            type = 'test'
            pass

        tabs.register_tab(TestTab)
        self.assertRaises(ValueError, tabs.register_tab, TestTab)
        tabs.register_tab(TestTab, force=True)
        self.assertIs(tabs.get_tab('test'), TestTab)
        tabs.register_tab(TestTab, name='test-with-name')
        self.assertIs(tabs.get_tab('test-with-name'), TestTab)
Esempio n. 3
0
            elif self.labels[i - 1] != str(flag):
                post.h4('%s (%s)' % (flag.name, self.labels[i - 1]),
                        class_='panel-title')
            else:
                post.h4(flag.name, class_='panel-title')
            post.a.close()
            post.div.close()
            post.div(id_='flag%d' % i, class_='panel-collapse collapse')
            post.div(class_='panel-body')
            # write segment summary
            post.p('This flag was defined and had a known state during '
                   'the following segments:')
            post.add(self.print_segments(flag.known))
            # write segment table
            post.p('This flag was active during the following segments:')
            post.add(self.print_segments(flag.active))

            post.div.close()
            post.div.close()
            post.div.close()
        post.div.close()

        # then write standard data tab
        return super(get_tab('default'), self).write_state_html(state,
                                                                plots=True,
                                                                pre=pre,
                                                                post=post)


register_tab(FlagTab)
Esempio n. 4
0
            if i == 0:
                post.h4(self.intersection and 'Intersection' or 'Union',
                        class_='panel-title')
            elif self.labels[i-1] != str(flag):
                post.h4('%s (%s)' % (flag.name, self.labels[i-1]),
                        class_='panel-title')
            else:
                post.h4(flag.name, class_='panel-title')
            post.a.close()
            post.div.close()
            post.div(id_='flag%d' % i, class_='panel-collapse collapse')
            post.div(class_='panel-body')
            # write segment summary
            post.p('This flag was defined and had a known state during '
                   'the following segments:')
            post.add(self.print_segments(flag.known))
            # write segment table
            post.p('This flag was active during the following segments:')
            post.add(self.print_segments(flag.active))

            post.div.close()
            post.div.close()
            post.div.close()
        post.div.close()

        # then write standard data tab
        return super(get_tab('default'), self).write_state_html(
            state, plots=True, pre=pre, post=post)

register_tab(FlagTab)