Beispiel #1
0
    def test_map_publish_deletion(self, mocker):
        setup_mocks(mocker)

        map = Map(Layer(Source('fake_table', credentials=self.credentials)))

        name = 'cf_publish'
        map.publish(name, None, credentials=self.credentials)
        response = map.delete_publication()

        assert response is True
Beispiel #2
0
    def test_map_publish_update_password(self, mocker):
        setup_mocks(mocker)

        map = Map(Layer(Source('fake_table', credentials=self.credentials)))

        name = 'cf_publish'
        map.publish(name, None, credentials=self.credentials)
        kuviz_dict = map.update_publication(name, '1234"')

        self.assert_kuviz_dict(kuviz_dict, name, 'password')
Beispiel #3
0
    def test_map_publish_with_password(self, mocker):
        setup_mocks(mocker)

        map = Map(Layer(Source('fake_table', credentials=self.credentials)))

        name = 'cf_publish'
        kuviz_dict = map.publish(name, '1234', credentials=self.credentials)
        self.assert_kuviz_dict(kuviz_dict, name, 'password')
Beispiel #4
0
    def test_map_publish_remote_default(self, mocker):
        setup_mocks(mocker)
        mock_set_content = mocker.patch(
            'cartoframes.viz.html.html_map.HTMLMap.set_content')

        vmap = Map(Layer('fake_table', credentials=self.credentials))

        name = 'cf_publish'
        kuviz_dict = vmap.publish(name, None, self.credentials)
        self.assert_kuviz_dict(kuviz_dict, name, 'public')
        mock_set_content.assert_called_once_with(
            _airship_path=None,
            _carto_vl_path=None,
            basemap='Positron',
            bounds=[[-180, -90], [180, 90]],
            camera=None,
            description=None,
            is_embed=True,
            is_static=None,
            layer_selector=False,
            layers=[{
                'credentials': {
                    'username': '******',
                    'api_key': 'fake_api_key',
                    'base_url': 'https://fake_username.carto.com'
                },
                'interactivity': [],
                'legends': [],
                'has_legend_list':
                True,
                'encode_data':
                True,
                'widgets': [],
                'data':
                'select * from fake_table',
                'type':
                'Query',
                'title':
                None,
                'options': {},
                'map_index':
                0,
                'source':
                'select * from fake_table',
                'viz':
                '''color: hex("#EE4D5A")
strokeColor: opacity(#222,ramp(linear(zoom(),0,18),[0,0.6]))
strokeWidth: ramp(linear(zoom(),0,18),[0,1])
width: ramp(linear(zoom(),0,18),[2,10])
'''
            }],
            show_info=False,
            size=None,
            theme=None,
            title='cf_publish')
Beispiel #5
0
    def test_map_publish_remote_params(self, mocker):
        setup_mocks(mocker)
        mock_set_content = mocker.patch(
            'cartoframes.viz.html.html_map.HTMLMap.set_content')

        vmap = Map(Layer('fake_table', credentials=self.credentials),
                   basemap='yellow',
                   bounds={
                       'west': 1,
                       'east': 2,
                       'north': 3,
                       'south': 4
                   },
                   viewport={
                       'zoom': 5,
                       'lat': 50,
                       'lng': -10
                   },
                   is_static=True,
                   theme='dark',
                   title='title',
                   description='description')

        name = 'cf_publish'
        kuviz_dict = vmap.publish(name, None, self.credentials)
        self.assert_kuviz_dict(kuviz_dict, name, 'public')
        mock_set_content.assert_called_once_with(_airship_path=None,
                                                 _carto_vl_path=None,
                                                 basemap='yellow',
                                                 bounds=[[1, 2], [4, 3]],
                                                 camera={
                                                     'bearing': None,
                                                     'center': [-10, 50],
                                                     'pitch': None,
                                                     'zoom': 5
                                                 },
                                                 description='description',
                                                 is_embed=True,
                                                 is_static=True,
                                                 layers=[],
                                                 show_info=False,
                                                 size=None,
                                                 theme='dark',
                                                 title='cf_publish')
Beispiel #6
0
    def test_map_publish_remote_default(self, mocker):
        setup_mocks(mocker)
        mock_set_content = mocker.patch(
            'cartoframes.viz.html.html_map.HTMLMap.set_content')

        vmap = Map(Layer('fake_table', credentials=self.credentials))

        name = 'cf_publish'
        kuviz_dict = vmap.publish(name, None, self.credentials)
        self.assert_kuviz_dict(kuviz_dict, name, 'public')
        mock_set_content.assert_called_once_with(_airship_path=None,
                                                 _carto_vl_path=None,
                                                 basemap='Positron',
                                                 bounds=[[-180, -90],
                                                         [180, 90]],
                                                 camera=None,
                                                 description=None,
                                                 is_embed=True,
                                                 is_static=None,
                                                 layers=[],
                                                 show_info=False,
                                                 size=None,
                                                 theme=None,
                                                 title='cf_publish')
Beispiel #7
0
    def test_map_publish_remote_params(self, mocker):
        setup_mocks(mocker)
        mock_set_content = mocker.patch(
            'cartoframes.viz.html.html_map.HTMLMap.set_content')

        vmap = Map(Layer('fake_table', credentials=self.credentials),
                   basemap='yellow',
                   bounds={
                       'west': 1,
                       'east': 2,
                       'north': 3,
                       'south': 4
                   },
                   viewport={
                       'zoom': 5,
                       'lat': 50,
                       'lng': -10
                   },
                   is_static=True,
                   layer_selector=False,
                   theme='dark',
                   title='title',
                   description='description')

        name = 'cf_publish'
        kuviz_dict = vmap.publish(name,
                                  None,
                                  self.credentials,
                                  maps_api_key='1234567890')
        self.assert_kuviz_dict(kuviz_dict, name, 'public')
        mock_set_content.assert_called_once_with(
            _airship_path=None,
            _carto_vl_path=None,
            basemap='yellow',
            bounds=[[1, 2], [4, 3]],
            camera={
                'bearing': None,
                'center': [-10, 50],
                'pitch': None,
                'zoom': 5
            },
            description='description',
            is_embed=True,
            is_static=True,
            layer_selector=False,
            layers=[{
                'credentials': {
                    'username': '******',
                    'api_key': '1234567890',
                    'base_url': 'https://fake_username.carto.com'
                },
                'interactivity': [],
                'legends': [],
                'has_legend_list':
                True,
                'encode_data':
                True,
                'widgets': [],
                'data':
                'select * from fake_table',
                'type':
                'Query',
                'title':
                None,
                'options': {},
                'map_index':
                0,
                'source':
                'select * from fake_table',
                'viz':
                '''color: hex("#EE4D5A")
strokeColor: opacity(#222,ramp(linear(zoom(),0,18),[0,0.6]))
strokeWidth: ramp(linear(zoom(),0,18),[0,1])
width: ramp(linear(zoom(),0,18),[2,10])
'''
            }],
            show_info=False,
            size=None,
            theme='dark',
            title='cf_publish')