Beispiel #1
0
    def test_from_dir(self):
        dirname = os.path.join(
            os.path.dirname(__file__),
            'fixtures',
            'etc')

        config = DiamondashConfig.from_dir(dirname)

        dashboard1_config, dashboard2_config = config['dashboards']

        self.assertTrue(isinstance(dashboard1_config, DashboardConfig))
        self.assertEqual(dashboard1_config['name'], 'dashboard-1')
        self.assertEqual(dashboard1_config['title'], 'Dashboard 1')

        widget1_config, = dashboard1_config['widgets']
        self.assertTrue(isinstance(widget1_config, WidgetConfig))
        self.assertEqual(widget1_config['name'], 'dashboard-1-widget-1')
        self.assertEqual(widget1_config['title'], 'Dashboard 1 Widget 1')
        self.assertEqual(
            widget1_config['backend']['url'],
            'http://127.0.0.1:8118')

        self.assertTrue(isinstance(dashboard2_config, DashboardConfig))
        self.assertEqual(dashboard2_config['name'], 'dashboard-2')
        self.assertEqual(dashboard2_config['title'], 'Dashboard 2')

        widget1_config, = dashboard2_config['widgets']
        self.assertTrue(isinstance(widget1_config, WidgetConfig))
        self.assertEqual(widget1_config['name'], 'dashboard-2-widget-1')
        self.assertEqual(widget1_config['title'], 'Dashboard 2 Widget 1')
        self.assertEqual(
            widget1_config['backend']['url'],
            'http://127.0.0.1:7118')
Beispiel #2
0
def makeService(options):
    config = DiamondashConfig.from_dir(options["config_dir"])
    diamondash = DiamondashServer(config)

    site = server.Site(diamondash.app.resource())
    diamondash_service = service.MultiService()
    strports_service = strports.service(options["port"], site)
    strports_service.setServiceParent(diamondash_service)

    return diamondash_service