예제 #1
0
 def test_staging(self):
     with patch.dict(
             'os.environ',
         {'GOVUK_APP_DOMAIN': 'staging.publishing.service.gov.uk'}):
         self.assertEqual(
             plek.find("tests-service"),
             "https://tests-service.staging.publishing.service.gov.uk")
예제 #2
0
 def test_defined_uri(self):
     with patch.dict('os.environ', {
             'PLEK_SERVICE_TEST_SERVICE_URI':
             'https://tests-service.gov.uk/path'
     }):
         self.assertEqual(plek.find("test-service"),
                          'https://tests-service.gov.uk/path')
def content_links_generator(page_size=1000,
                            additional_search_fields = {},
                            rummager_url=plek.find('search-api'),
                            blacklist_document_types=[]):
    search_dict = merge({'reject_content_store_document_type': blacklist_document_types,
                         'fields': ['link'],
                         'debug': 'include_withdrawn'},
                        additional_search_fields)
    search_results = rummager.Rummager(rummager_url).search_generator(search_dict, page_size=page_size)
    return map(lambda h: h.get('link'), search_results)
def get_content(base_path,
                content_store_url=plek.find('content-store')):
    content_dict = __get_content_dict(base_path, content_store_url)

    if not content_dict:
        return False

    # Skip this if we don't get back the content we expect, e.g. if
    # the Content Store has redirected the request
    if content_dict.get('base_path') != base_path:
        return False

    # Skip anything without a content_id
    if 'content_id' not in content_dict:
        return False

    return content_dict
예제 #5
0
def __get_all_content(blacklist_document_types=[]):
    get_content = functools.partial(
        content_export.get_content,
        content_store_url=plek.find('content-store'))

    progress_bar = jenkins_compatible_progress_bar()

    content_links_list = list(
        progress_bar(
            content_export.content_links_generator(
                blacklist_document_types=blacklist_document_types)))

    content_links_set = set(content_links_list)
    duplicate_links = len(content_links_list) - len(content_links_set)

    if duplicate_links > 0:
        print("{} duplicate links from Rummager".format(duplicate_links))

    pool = Pool(4)
    return pool.imap(get_content, content_links_set), len(content_links_set)
 def __init__(self, base_url=plek.find("search-api")):
     self.base_url = base_url
예제 #7
0
 def test_dev_domain(self):
     self.assertEqual(plek.find("tests-service"),
                      "http://tests-service.dev.gov.uk")
예제 #8
0
def content_store_has_item(path, json):
    responses.add(responses.GET,
                  plek.find("content-store") + "/content" + path,
                  json=json,
                  status=200)
예제 #9
0
 def __init__(self, key_list=("content_id", "base_path", "title"),
              content_store_url=plek.find("content-store")):
     self.content_store_url = content_store_url
     self.key_list = key_list