def test_multiple_company_id_filter(app):
    url = 'http://localhost:80/api/v1/get-company-countries-and-sectors-of-interest'
    with app.test_client() as app_context:
        utils.assert_api_response(
            app_context=app_context,
            api=url,
            params='service-company-id=2&service-company-id=1',
            expected_response=(
                200,
                {
                    'headers': [
                        'serviceCompanyId',
                        'companyMatchId',
                        'country',
                        'sector',
                        'type',
                        'service',
                        'source',
                        'sourceId',
                        'timestamp',
                    ],
                    'next': None,
                    'values': [list(entry_1.values()), list(entry_2.values())],
                },
            ),
        )
Esempio n. 2
0
def test_get_sectors(app):
    with mock.patch('app.sso.token.is_authenticated') as mock_is_authenticated:
        mock_is_authenticated.return_value = True
        url = 'http://localhost:80/api/v1/get-data-visualisation-data/sector'
        with app.test_client() as app_context:
            utils.assert_api_response(
                app_context=app_context,
                api=url,
                params='data-source=omis',
                expected_response=(
                    200,
                    {
                        'nInterests': [
                            {
                                'date': '2009-10-01T00:00:00',
                                'nInterests': 1,
                                'nInterestsCumulative': 1,
                                'sector': 'sector1',
                                'shareOfInterest': 0.5,
                                'shareOfInterestCumulative': 0.5,
                            },
                            {
                                'date': '2009-10-01T00:00:00',
                                'nInterests': 1,
                                'nInterestsCumulative': 1,
                                'sector': 'sector3',
                                'shareOfInterest': 0.5,
                                'shareOfInterestCumulative': 0.5,
                            },
                        ],
                        'top': ['sector1', 'sector3'],
                    },
                ),
            )
def test_pagination_next(app):
    old_pagination_size = app.config['app']['pagination_size']
    app.config['app']['pagination_size'] = 1
    url = 'http://localhost:80/api/v1/get-company-countries-and-sectors-of-interest'
    with app.test_client() as app_context:
        utils.assert_api_response(
            app_context=app_context,
            api=url,
            params='',
            expected_response=(
                200,
                {
                    'headers': [
                        'serviceCompanyId',
                        'companyMatchId',
                        'country',
                        'sector',
                        'type',
                        'service',
                        'source',
                        'sourceId',
                        'timestamp',
                    ],
                    'next': 'http://localhost/api/v1/'
                    'get-company-countries-and-sectors-of-interest?'
                    'orientation=tabular&'
                    'next-id=2',
                    'values': [list(entry_1.values())],
                },
            ),
        )
    app.config['app']['pagination_size'] = old_pagination_size
Esempio n. 4
0
def test_invalid_sector_data_source(app):
    with mock.patch('app.sso.token.is_authenticated') as mock_is_authenticated:
        mock_is_authenticated.return_value = True
        url = 'http://localhost:80/api/v1/get-data-visualisation-data/sector'
        with app.test_client() as app_context:
            utils.assert_api_response(
                app_context=app_context,
                api=url,
                params='data-source=interactions',
                expected_response=(400, None),
            )