Esempio n. 1
0
 def setUp(self):
     generator = create_generator()
     generator.generate_context()
     conf_factory = ConfFactory()
     conf_factory.configure(CONF_FILE)
     self.data_factory = conf_factory.data_factory
     self.data_factory.parse_data(generator.articles)
Esempio n. 2
0
 def setUp(self):
     generator = create_generator(CONTENT_DIR)
     generator.generate_context()
     conf_factory = ConfFactory()
     conf_factory.configure(CONF_FILE)
     self.data_factory = conf_factory.data_factory
     self.data_factory.parse_data(generator.articles)
Esempio n. 3
0
class TestConf(unittest.TestCase):
    def setUp(self):
        self.conf_factory = ConfFactory()

    def test_load_conf(self):
        # top_article_error shall be in the configuration since the error is only detected at runtime
        expected_result = ['nb_article_by_genre_year', 'top_article_by_writer', 'nb_article_by_ranking',
                           'nb_article_by_ranking_year', 'nb_article_by_genre', 'nb_article_by_year',
                           'top_article_error']
        self.conf_factory.configure(CONF_FILE)
        self.assertEqual(set(self.conf_factory.confs.keys()), set(expected_result))

    def test_chart_configuration(self):
        self.conf_factory.configure(CONF_FILE)
        self.chart_factory = self.conf_factory.chart_factory
        data = Series({'BD': 4, 'Divers': 1, 'Jeunesse': 1, 'Roman': 3, 'Roman Noir': 1})
        # Testing a default value
        renderer = partial(self.chart_factory.get_renderer(class_name='pieChart'), name='pie_chart')
        chart = self.chart_factory.render(data=data, renderer=renderer)
        self.assertEquals(chart.width, '700')
        # Testing a value overriden
        renderer = partial(self.chart_factory.get_renderer(class_name='discreteBarChart'), name='bar_chart')
        chart = self.chart_factory.render(data=data, renderer=renderer)
        self.assertEquals(chart.width, '500')

    def test_load_bad_conf(self):
        expected_result = ['nb_article_by_error']
        self.conf_factory.configure(CONF_ERR_FILE)
        self.assertEqual(set(self.conf_factory.confs.keys()), set(expected_result))
Esempio n. 4
0
class TestConf(unittest.TestCase):
    def setUp(self):
        self.conf_factory = ConfFactory()

    def test_load_conf(self):
        # top_article_error shall be in the configuration since the error is only detected at runtime
        expected_result = [
            "nb_article_by_genre_year",
            "top_article_by_writer",
            "nb_article_by_ranking",
            "nb_article_by_ranking_year",
            "nb_article_by_genre",
            "nb_article_by_year",
            "top_article_error",
            "nb_article_by_month",
        ]
        self.conf_factory.configure(CONF_FILE)
        self.assertEqual(set(self.conf_factory.confs.keys()),
                         set(expected_result))

    def test_chart_configuration(self):
        self.conf_factory.configure(CONF_FILE)
        self.chart_factory = self.conf_factory.chart_factory
        data = Series({
            "BD": 4,
            "Divers": 1,
            "Jeunesse": 1,
            "Roman": 3,
            "Roman Noir": 1
        })
        # Testing a default value
        renderer = partial(
            self.chart_factory.get_renderer(class_name="pieChart"),
            name="pie_chart")
        chart = self.chart_factory.render(data=data, renderer=renderer)
        self.assertEquals(chart.width, "700")
        # Testing a value overriden
        renderer = partial(
            self.chart_factory.get_renderer(class_name="discreteBarChart"),
            name="bar_chart",
        )
        chart = self.chart_factory.render(data=data, renderer=renderer)
        self.assertEquals(chart.width, "500")

    def test_load_bad_conf(self):
        expected_result = ["nb_article_by_error"]
        self.conf_factory.configure(CONF_ERR_FILE)
        self.assertEqual(set(self.conf_factory.confs.keys()),
                         set(expected_result))
Esempio n. 5
0
class TestConf(unittest.TestCase):
    def setUp(self):
        self.conf_factory = ConfFactory()

    def test_load_conf(self):
        # top_article_error shall be in the configuration since the error is only detected at runtime
        expected_result = [
            'nb_article_by_genre_year', 'top_article_by_writer',
            'nb_article_by_ranking', 'nb_article_by_ranking_year',
            'nb_article_by_genre', 'nb_article_by_year', 'top_article_error',
            'nb_article_by_month'
        ]
        self.conf_factory.configure(CONF_FILE)
        self.assertEqual(set(self.conf_factory.confs.keys()),
                         set(expected_result))

    def test_chart_configuration(self):
        self.conf_factory.configure(CONF_FILE)
        self.chart_factory = self.conf_factory.chart_factory
        data = Series({
            'BD': 4,
            'Divers': 1,
            'Jeunesse': 1,
            'Roman': 3,
            'Roman Noir': 1
        })
        # Testing a default value
        renderer = partial(
            self.chart_factory.get_renderer(class_name='pieChart'),
            name='pie_chart')
        chart = self.chart_factory.render(data=data, renderer=renderer)
        self.assertEquals(chart.width, '700')
        # Testing a value overriden
        renderer = partial(
            self.chart_factory.get_renderer(class_name='discreteBarChart'),
            name='bar_chart')
        chart = self.chart_factory.render(data=data, renderer=renderer)
        self.assertEquals(chart.width, '500')

    def test_load_bad_conf(self):
        expected_result = ['nb_article_by_error']
        self.conf_factory.configure(CONF_ERR_FILE)
        self.assertEqual(set(self.conf_factory.confs.keys()),
                         set(expected_result))
Esempio n. 6
0
 def setUp(self):
     self.conf_factory = ConfFactory()
Esempio n. 7
0
 def setUp(self):
     self.conf_factory = ConfFactory()