Beispiel #1
0
    def test_vector_interactivity(self):
        """contrib.vector"""
        cc = cartoframes.CartoContext(base_url=self.baseurl,
                                      api_key=self.apikey)
        layers = [
            vector.Layer(self.points, interactivity='body'),
            vector.QueryLayer('SELECT * FROM {}'.format(self.polys),
                              interactivity=[
                                  'name',
                                  'state_name',
                              ]),
            vector.QueryLayer('SELECT * FROM {}'.format(self.polys),
                              interactivity={
                                  'cols': [
                                      'name',
                                      'state_name',
                                  ],
                                  'header': '<h1 class="h1">NAT</h1>',
                                  'event': 'click'
                              })
        ]
        self.assertIsInstance(vector.vmap(layers, cc), HTML)

        # invalid entry for interactivity
        with self.assertRaises(ValueError):
            vector.vmap([
                vector.Layer(self.points, interactivity=10),
            ])
 def test_vector_multilayer(self):
     """contrib.vector"""
     cc = cartoframes.CartoContext(base_url=self.baseurl,
                                   api_key=self.apikey)
     layers = [
         vector.Layer(self.points, color='red', size=10, strokeColor='blue'),
         vector.QueryLayer(
             'SELECT * FROM {}'.format(self.polys),
             time='torque($cartodb_id, 10)', strokeWidth=2)
     ]
     self.assertIsInstance(vector.vmap(layers, cc), HTML)
 def test_vector_local(self):
     """contrib.vector local with"""
     cc = cartoframes.CartoContext(base_url=self.baseurl,
                                   api_key=self.apikey)
     with self.assertRaises(ValueError):
         df = cc.query('''
                 select the_geom, the_geom_webmercator, cartodb_id
                 from {}
             '''.format(self.local),
             decode_geom=True)
         layers = [
             vector.Layer(self.points, color='red', size=10, strokeColor='blue'),
             vector.QueryLayer(
                 'SELECT * FROM {}'.format(self.polys),
                 time='torque($cartodb_id, 10)', strokeWidth=2),
             vector.LocalLayer(df)
         ]
         self.assertIsInstance(vector.vmap(layers, cc), HTML)