def test_create_image_with_image_id(self, context):
        """
        <b>Description:</b>
        Checks if new image with the given id can be created.

        <b>Input data:</b>
        1. image id: generated test name
        2. image type: JAVA
        3. image state: REQUESTED

        <b>Expected results:</b>
        Test passes when new image can be created. According to this, image should be available on the list of images
        after being created.

        <b>Steps:</b>
        1. Create image with the given id.
        2. Check that the image is on the list of catalog images.
        """
        step("Create image with image_id")
        catalog_image = CatalogImage.create(
            context,
            image_id=generate_test_object_name(),
            image_type=TapApplicationType.JAVA,
            state=TapEntityState.REQUESTED)
        step("Check that the image is on the list of catalog images")
        images = CatalogImage.get_list()
        assert catalog_image in images
    def test_update_catalog_image_type(self, context):
        """
        <b>Description:</b>
        Checks if value of image type can be updated.

        <b>Input data:</b>
        1. image type: JAVA
        2. image state: REQUESTED

        <b>Expected results:</b>
        Test passes when value of image type is updated.

        <b>Steps:</b>
        1. Create catalog image with image type: JAVA, state: REQUESTED.
        2. Update image type on GO.
        3. Check that the image was updated
        """
        step("Create catalog image with image type JAVA")
        test_image = CatalogImage.create(context,
                                         image_type=TapApplicationType.JAVA,
                                         state=TapEntityState.REQUESTED)

        step("Update image type on GO")
        test_image.update(field_name="type", value=TapApplicationType.GO)

        step("Check that the image was updated")
        image = CatalogImage.get(image_id=test_image.id)
        assert test_image == image
Exemple #3
0
    def catalog_image(self, context):
        log_fixture("CATALOG: Send application metadata - create an image")
        catalog_image = CatalogImage.create(context,
                                            image_type=self.APP_TYPE,
                                            state=self.INITIAL_IMAGE_STATE,
                                            blob_type=self.BLOB_TYPE)

        catalog_image.ensure_in_state(TapEntityState.REQUESTED)

        log_fixture("CATALOG: Check that the image is on the image list")
        catalog_images = CatalogImage.get_list()
        assert catalog_image in catalog_images
        return catalog_image
    def test_create_image_with_empty_body(self, context):
        """
        <b>Description:</b>
        Checks if there is possibility of creating image with empty body: {}.

        <b>Input data:</b>
        no input data

        <b>Expected results:</b>
        Test passes when image is created. According to this, image should be available on the list of images and
        should has automatically generated id.

        <b>Steps:</b>
        1. Create image with empty body: {}.
        """
        step("Create image with empty_body")
        catalog_image = CatalogImage.create(context)
        step("Check that the image is on the list of catalog images")
        images = CatalogImage.get_list()
        assert catalog_image in images
    def test_create_and_delete_catalog_image(self, context):
        """
        <b>Description:</b>
        Checks if new image can be created and deleted.

        <b>Input data:</b>
        1. image type: JAVA
        2. image state: REQUESTED

        <b>Expected results:</b>
        Test passes when new image can be created and deleted. According to this, image should be available on the
        list of images after being created and shouldn't be on this list after deletion.

        <b>Steps:</b>
        1. Create image.
        2. Check that the image is on the list of catalog images.
        3. Delete the image.
        4. Check that image is no longer on the list of catalog images.
        """
        step("Create catalog image")
        catalog_image = CatalogImage.create(context,
                                            image_type=TapApplicationType.JAVA,
                                            state=TapEntityState.REQUESTED)

        step("Check that the image is on list of catalog images")
        images = CatalogImage.get_list()
        assert catalog_image in images

        step("Delete the image")
        catalog_image.delete()

        step("Check that the image was deleted")
        images = CatalogImage.get_list()
        assert catalog_image not in images

        step("Check that getting the deleted image returns an error")
        # TODO this error message should be different
        assert_raises_http_exception(CatalogHttpStatus.CODE_NOT_FOUND,
                                     CatalogHttpStatus.MSG_KEY_NOT_FOUND,
                                     CatalogImage.get,
                                     image_id=catalog_image.id)
    def test_update_catalog_image_state(self, context, test_sample_apps):
        """
        <b>Description:</b>
        Checks if value of image state can be updated.

        <b>Input data:</b>
        1. image type: JAVA
        2. image state: REQUESTED

        <b>Expected results:</b>
        Test passes when value of image state is updated.

        <b>Steps:</b>
        1. Create catalog image with image type: JAVA, state: REQUESTED.
        2. Update image state on PENDING.
        3. Check that the image was updated.
        """
        step("Create catalog image with image state REQUESTED")
        test_image = CatalogImage.create(context,
                                         image_type=TapApplicationType.JAVA,
                                         state=TapEntityState.REQUESTED,
                                         blob_type="TARGZ")

        test_image.ensure_in_state(TapEntityState.REQUESTED)

        Blob.create_from_file(context,
                              blob_id=test_image.id,
                              file_path=test_sample_apps[
                                  SampleAppKeys.TAPNG_NODEJS_APP].filepath)

        Image.create(context, image_id=test_image.id)
        image = CatalogImage.get(image_id=test_image.id)
        image.ensure_in_state(TapEntityState.REQUESTED)

        step("Update image state on PENDING")
        test_image.update(field_name="state", value=TapEntityState.PENDING)

        step("Check that the image state was changed to READY or BUILDING")
        image = CatalogImage.get(image_id=test_image.id)
        assert image.state == TapEntityState.BUILDING or image.state == TapEntityState.READY
Exemple #7
0
def catalog_image(class_context):
    log_fixture("Create sample image in catalog")
    return CatalogImage.create(class_context)
 def sample_catalog_image(self, class_context):
     log_fixture("Create sample catalog image")
     return CatalogImage.create(class_context,
                                image_type=TapApplicationType.JAVA,
                                state=TapEntityState.REQUESTED)