Esempio n. 1
0
    def setup_method(self, method):
        super().setup_method(method)

        self._lots_by_slug = framework_helpers.get_lots_by_slug(
            self._get_framework_fixture_data('g-cloud-6')['frameworks'])

        self._g9_lots_by_slug = framework_helpers.get_lots_by_slug(
            self._get_framework_fixture_data('g-cloud-9')['frameworks'])

        self.fixture = _get_fixture_data()
        self.search_results = SearchResults(self.fixture, self._lots_by_slug)
        self.request_args = MultiDict((
            ('lot', 'saas'),
            ('q', 'email'),
        ))
 def test_get_lots_by_slug(self):
     g_cloud_9_data = next(
         (f for f in self.available_frameworks if f['slug'] == 'g-cloud-9'))
     lots_by_slug = get_lots_by_slug(g_cloud_9_data)
     assert lots_by_slug['cloud-hosting'] == g_cloud_9_data['lots'][0]
     assert lots_by_slug['cloud-software'] == g_cloud_9_data['lots'][1]
     assert lots_by_slug['cloud-support'] == g_cloud_9_data['lots'][2]
Esempio n. 3
0
    def setup_method(self, method):
        super().setup_method(method)

        self.fixture = _get_fixture_data()
        self.multiple_pages_fixture = _get_fixture_multiple_pages_data()
        self._lots_by_slug = framework_helpers.get_lots_by_slug(
            self._get_framework_fixture_data('g-cloud-6')['frameworks'])
Esempio n. 4
0
 def setup(self):
     self.lot_filters = [
         {
             'label':
             'section1',
             'filters': [
                 {
                     'name': 'question1',
                     'value': 'true'
                 },
                 {
                     'name': 'question2',
                     'value': 'true'
                 },
                 {
                     'name': 'question3',
                     'value': 'option1'
                 },
                 {
                     'name': 'question3',
                     'value': 'option2'
                 },
                 {
                     'name': 'question3',
                     'value': 'option3'
                 },
             ]
         },
         {
             'label':
             'section2',
             'filters': [
                 {
                     'name': 'question4',
                     'value': 'true'
                 },
                 {
                     'name': 'question5',
                     'value': 'true'
                 },
                 {
                     'name': 'question6',
                     'value': 'option1'
                 },
                 {
                     'name': 'question6',
                     'value': 'option2'
                 },
                 {
                     'name': 'question6',
                     'value': 'option3'
                 },
             ]
         },
     ]
     self._lots_by_slug = framework_helpers.get_lots_by_slug(
         self._get_framework_fixture_data('g-cloud-6')['frameworks'])
     self.g6_framework = self._get_framework_fixture_data(
         'g-cloud-6')['frameworks']
    def setup_method(self, method):
        super().setup_method(method)

        self.fixture = _get_fixture_data()
        self.fixture = self.fixture['services']
        self._lots_by_slug = framework_helpers.get_lots_by_slug(
            self._get_framework_fixture_data('g-cloud-6')['frameworks'])

        self.service = Service(
            self.fixture,
            content_loader.get_manifest('g-cloud-6', 'display_service'),
            self._lots_by_slug)
    def setup_method(self, method):
        super().setup_method(method)

        self.supplier = self._get_supplier_fixture_data()
        self.service = self._get_g6_service_fixture_data()

        self.data_api_client.get_supplier.return_value = self.supplier
        self.data_api_client.get_framework.return_value = self._get_framework_fixture_data('g-cloud-6')
        self.data_api_client.get_service.return_value = self.service

        self.lots = framework_helpers.get_lots_by_slug(
            self._get_framework_fixture_data('g-cloud-6')['frameworks']
        )
    def __init__(self,
                 search_api_client,
                 search_api_url,
                 frameworks_by_slug,
                 include_markup=False):
        # Get core data
        self.framework_slug = search_api_client.get_index_from_search_api_url(
            search_api_url)
        framework = frameworks_by_slug[self.framework_slug]
        content_manifest = content_loader.get_manifest(
            self.framework_slug, 'services_search_filters')
        lots_by_slug = get_lots_by_slug(framework)

        # We need to get buyer-frontend query params from our saved search API URL.
        search_query_params = search_api_client.get_frontend_params_from_search_api_url(
            search_api_url)
        search_query_params = ungroup_request_filters(search_query_params,
                                                      content_manifest)
        search_query_params_multidict = MultiDict(search_query_params)

        current_lot_slug = search_query_params_multidict.get('lot', None)
        filters = filters_for_lot(current_lot_slug,
                                  content_manifest,
                                  all_lots=framework['lots'])
        clean_request_query_params = clean_request_args(
            search_query_params_multidict, filters.values(), lots_by_slug)

        # Now build the buyer-frontend URL representing the saved Search API URL
        self.url = construct_url_from_base_and_params(
            url_for('main.search_services'), search_query_params)

        # Get the saved Search API URL result set and build the search summary.
        search_api_response = search_api_client._get(search_api_url)
        self.search_summary = SearchSummary(
            search_api_response['meta']['total'],
            clean_request_query_params.copy(), filters.values(), lots_by_slug)