Esempio n. 1
0
 def test_no_options(self):
     ''' Tests if default state-municipalities (vision-res) is returned when
         no option is given '''
     self.assertEqual(
         Choropleth().get_geometry_loc(None, '1111111'),
         f'{Choropleth().BASE_TOPOJSON_REPO}/uf/municipio/11_q1.json'
     )
Esempio n. 2
0
 def test_default_state_municipality(self):
     ''' Tests if default state-municipalities is loaded when vision and ID are
         passed as expected '''
     self.assertEqual(
         Choropleth().get_geometry_loc({'visao': 'uf'}, '1111111'),
         f'{Choropleth().BASE_TOPOJSON_REPO}/uf/municipio/11_q1.json'
     )
Esempio n. 3
0
 def test_no_analysis_unit(self):
     ''' Tests if default br-states (vision-res) is returned when no
         analysis unit ID is given '''
     self.assertEqual(
         Choropleth().get_geometry_loc({}, None),
         f'{Choropleth().BASE_TOPOJSON_REPO}/uf_q1.json'
     )
Esempio n. 4
0
 def test_default_state_municipality_quality_2(self):
     ''' Tests if quality level is set accordingly '''
     self.assertEqual(
         Choropleth().get_geometry_loc(
             {'visao': 'uf', 'chart_options': {'quality': 2}},
             '1111111'
         ),
         f'{Choropleth().BASE_TOPOJSON_REPO}/uf/municipio/11_q2.json'
     )
Esempio n. 5
0
 def test_location(self):
     ''' Tests if appropriate location is returned when all options are set
         correctly '''
     self.assertEqual(
         Choropleth().get_geometry_loc(
             {'visao': 'distrito', 'chart_options': {'resolution': 'subdistrito'}},
             '111111111'
         ),
         f'{Choropleth().BASE_TOPOJSON_REPO}/distrito/subdistrito/111111111_q1.json'
     )
Esempio n. 6
0
 def test_same_vision_and_resolution(self):
     ''' Tests if the appropriate topology location is returned when the
         vision matches the resolution '''
     self.assertEqual(
         Choropleth().get_geometry_loc(
             {'visao': 'uf', 'chart_options': {'resolution': 'uf'}},
             '11'
         ),
         f'{Choropleth().BASE_TOPOJSON_REPO}/uf/11_q1.json'
     )
Esempio n. 7
0
 def test_default_topology_uf(self):
     ''' Tests if default br-states (vision-res) is returned when a state ID
         is passed as the analysis unit and the topology is set to uf '''
     self.assertEqual(
         Choropleth().get_geometry_loc(
             {'chart_options': {'topology': 'uf'}},
             '11'
         ),
         f'{Choropleth().BASE_TOPOJSON_REPO}/uf_q1.json'
     )
Esempio n. 8
0
    def create(cls,
               options={"chart_type": "LINE"},
               dataframe=None,
               mixed_type=None):
        """ Factory method """
        chart = None
        if mixed_type:
            if mixed_type == 'MIXED_MAP':
                chart = Mixed([
                    cls.create(each_option, each_dataframe)
                    for each_option, each_dataframe in zip(options, dataframe)
                ])
        else:
            if options.get('chart_type') == 'MAP_TOPOJSON':
                chart = Choropleth(options, dataframe)
            if options.get('chart_type') == 'MAP_HEAT':
                chart = Heat(options, dataframe)
            if options.get('chart_type') == 'MAP_CLUSTER':
                chart = Cluster(options, dataframe)
            if options.get('chart_type') == 'MAP_BUBBLES':
                chart = Bubbles(options, dataframe)
            if options.get('chart_type') == 'BAR':
                # TODO - [REMOVE] Options for color testing
                # options.get('chart_options')["colorArray"] = ["#FF0000", "blue", "green"]

                # TODO - [REMOVE] Options for horizontal bars
                # options['chart_options']['orientation'] = "horizontal"
                # options['chart_options']['y'] = "nu_competencia"
                # options['chart_options']['x'] = "vl_indicador"
                # options['chart_options']['show_x_axis'] = False
                # options['chart_options']['show_y_axis'] = True

                # TODO - [REMOVE] Options for stacked bars
                # options.get('chart_options')['stacked'] = True

                # TODO - [REMOVE] Options for horizontal pyramid bars
                # options.get('chart_options')['left'] = ['Feminino']
                # options['chart_options']['orientation'] = "horizontal"
                # options['chart_options']['y'] = "cut"
                # options['chart_options']['x'] = "agr_count"
                # options['chart_options']['show_x_axis'] = False
                # options['chart_options']['show_y_axis'] = True
                # del options['chart_options']['legend_field']
                chart = cls.select_bar_by_options(options, dataframe)
            if options.get('chart_type') == 'LINE':
                # TODO - [REMOVE] Options for stacked lines
                # options.get('chart_options')['stacked'] = True
                chart = cls.select_line_by_options(options, dataframe)
        return chart