Beispiel #1
0
    def test_publish_draft_services_happy_path(self, copy_draft_documents,
                                               publish_draft_service,
                                               get_draft_services_iter,
                                               dry_run, draft_ids_file):
        get_draft_services_iter.side_effect = self.find_draft_services_iter_side_effect
        # Assume the drafts have not been previously published
        publish_draft_service.return_value = ("serviceID", False)

        publish_draft_services(
            self.mock_data_api_client,
            "g-cloud-123",
            'draft-bucket',
            'documents-bucket',
            self.document_keys,
            self.live_assets_endpoint,
            draft_ids_file=draft_ids_file,
            dry_run=dry_run,
        )

        assert publish_draft_service.mock_calls == [
            mock.call(
                self.mock_data_api_client,
                self.draft_service1,
                dry_run=dry_run,
            ),
            mock.call(
                self.mock_data_api_client,
                self.draft_service2,
                dry_run=dry_run,
            )
        ]
        assert copy_draft_documents.mock_calls == [
            mock.call('draft-bucket', 'documents-bucket', self.document_keys,
                      self.live_assets_endpoint,
                      ExactIdentity(self.mock_data_api_client), "g-cloud-123",
                      self.draft_service1, "serviceID", dry_run),
            mock.call('draft-bucket', 'documents-bucket', self.document_keys,
                      self.live_assets_endpoint,
                      ExactIdentity(self.mock_data_api_client), "g-cloud-123",
                      self.draft_service2, "serviceID", dry_run),
        ]
        assert get_draft_services_iter.mock_calls == [
            mock.call(ExactIdentity(self.mock_data_api_client),
                      'g-cloud-123',
                      draft_ids_file=draft_ids_file)
        ]
Beispiel #2
0
    def test_publish_draft_services_does_not_copy_if_copy_flag_false(
            self, copy_draft_documents, publish_draft_service,
            get_draft_services_iter, dry_run, skip_docs_flag):
        get_draft_services_iter.side_effect = self.find_draft_services_iter_side_effect
        # Not yet published
        publish_draft_service.return_value = ("serviceID", False)

        publish_draft_services(self.mock_data_api_client,
                               "g-cloud-123",
                               'draft-bucket',
                               'documents-bucket',
                               self.document_keys,
                               self.live_assets_endpoint,
                               dry_run=dry_run,
                               skip_docs_if_published=skip_docs_flag,
                               copy_documents=False)
        assert len(copy_draft_documents.mock_calls) == 0
Beispiel #3
0
    def test_publish_draft_services_skips_copying_if_draft_already_published(
            self, copy_draft_documents, publish_draft_service,
            get_draft_services_iter, dry_run, draft_ids_file):
        get_draft_services_iter.side_effect = self.find_draft_services_iter_side_effect
        # Already published
        publish_draft_service.return_value = ("serviceID", True)

        publish_draft_services(
            self.mock_data_api_client,
            "g-cloud-123",
            'draft-bucket',
            'documents-bucket',
            self.document_keys,
            self.live_assets_endpoint,
            draft_ids_file=draft_ids_file,
            dry_run=dry_run,
        )
        assert len(copy_draft_documents.mock_calls) == 0
    framework = client.get_framework(FRAMEWORK_SLUG)["frameworks"]
    if framework["status"] not in _expected_framework_statuses:
        raise ValueError(
            f"Framework status expected to be one of {_expected_framework_statuses}, not {framework['status']!r}"
        )

    document_keys = _document_keys_by_framework_family.get(framework["family"])

    if document_keys and not (DRAFT_BUCKET and DOCUMENTS_BUCKET):
        raise ValueError(
            f"Must supply both <draft_bucket> and <documents_bucket> arguments for framework {FRAMEWORK_SLUG!r}"
        )

    try:
        _assets_endpoint = get_assets_endpoint_from_stage(STAGE)
    except (KeyError, NotImplementedError):
        _assets_endpoint = "https://dummy.endpoint"

    publish_draft_services(
        client,
        FRAMEWORK_SLUG,
        DRAFT_BUCKET,
        DOCUMENTS_BUCKET,
        document_keys,
        _assets_endpoint,
        draft_ids_file=DRAFT_IDS_FILE,
        dry_run=DRY_RUN,
        skip_docs_if_published=SKIP_DOCS_IF_PUBLISHED,
        copy_documents=bool(document_keys)
    )