Example #1
0
    def test_names(self):
        tile = call(tiles_test.TileTest.test_insert)
        self.assertNotIn(
            'name',
            select_default_series_spec_options(tile.report_id,
                                               tile.series_specs())[0])

        tile_config = tile.get_tile_config()
        for i, ss in enumerate(tile_config['series_spec_list']):
            ss.set_name('serie%d' % i)
        tile = tile.insert_similar(tile_config)
        update_default_options(tile)
        self.assertEqual(
            'serie0',
            select_default_series_spec_options(tile.report_id,
                                               tile.series_specs())[0]['name'])
        self.assertEqual(
            'serie1',
            select_default_series_spec_options(tile.report_id,
                                               tile.series_specs())[1]['name'])

        tile_config = tile.get_tile_config()
        for i, ss in enumerate(tile_config['series_spec_list']):
            ss.set_name('s%d' % i)
        tile = tile.insert_similar(tile_config)
        update_default_options(tile)
        self.assertEqual(
            's0',
            select_default_series_spec_options(tile.report_id,
                                               tile.series_specs())[0]['name'])
        self.assertEqual(
            's1',
            select_default_series_spec_options(tile.report_id,
                                               tile.series_specs())[1]['name'])
Example #2
0
    def test_colors(self):
        from mqe.tests import tiles_test

        tile = call(tiles_test.TileTest.test_insert,
                    tile_options_ext={'colors': ['red', 'blue']})
        update_default_options(tile)
        default_options = select_default_series_spec_options(
            tile.report_id, tile.series_specs())
        self.assertEqual([{
            'color': 'red'
        }, {
            'color': 'blue'
        }], default_options)

        tile2 = call(tiles_test.TileTest.test_insert)
        default_options = select_default_series_spec_options(
            tile2.report_id, tile2.series_specs())
        self.assertEqual([{
            'color': 'red'
        }, {
            'color': 'blue'
        }], default_options)

        tile3 = call(tiles_test.TileTest.test_insert,
                     tile_options_ext={'colors': ['pink']})
        update_default_options(tile3)

        default_options = select_default_series_spec_options(
            tile3.report_id, tile3.series_specs())
        self.assertEqual([{
            'color': 'pink'
        }, {
            'color': 'blue'
        }], default_options)

        tile4 = call(tiles_test.TileTest.test_insert)
        update_default_options(tile4)
        default_options = select_default_series_spec_options(
            tile4.report_id, tile4.series_specs())
        self.assertEqual([{
            'color': 'pink'
        }, {
            'color': 'blue'
        }], default_options)
Example #3
0
 def _set_combined_colors(self, data):
     if not data.get('series_data'):
         return
     default_options_list = dataseries.select_default_series_spec_options(
         self.tile.report_id, self.tile.series_specs())
     # compute combined_colors
     data['combined_colors'] = []
     for series_index, series_data in enumerate(data['series_data']):
         tw_color = safeget(self.tile_options.get('colors'), series_index)
         if tw_color:
             data['combined_colors'].append(tw_color)
             continue
         default_color = nestedget(default_options_list[series_index],
                                   'color')
         if default_color:
             data['combined_colors'].append(default_color)
             continue
         fallback_color = cyclicget(mqeconfig.DEFAULT_COLORS, series_index)
         data['combined_colors'].append(fallback_color)