コード例 #1
0
class ListVersions(ImagesFixture):

    @data_driven_test(ImagesDatasetListGenerator.Versions())
    def ddtest_list_versions(self, url_addition):
        """
        @summary: List all versions

        @param url_addition: Parameter being passed to the list versions
        request
        @type url_addition: Dictionary

        1) Retrieve the versions data file
        2) List all versions passing in each url addition
        3) Verify that the response code is 300
        4) Verify that the number of versions received matches the number of
        versions in the versions data file
        5) For each version returned, verify that the data matches the
        versions data file
        """

        errors = []

        versions_data = self.images.behaviors.get_comparison_data(
            self.images.config.versions_data)

        resp = self.images.client.list_versions(url_addition)
        self.assertEqual(
            resp.status_code, 300,
            Messages.STATUS_CODE_MSG.format(300, resp.status_code))
        listed_versions = resp.entity

        self.assertEqual(len(listed_versions), len(versions_data))

        for version in listed_versions:
            version_data = versions_data[version.id_]

            if version.links[0].href != version_data.get('href'):
                errors.append(self.error_msg.format(
                    'href', version_data.get('href'), version.links[0].href))
            if version.links[0].rel != version_data.get('rel'):
                errors.append(self.error_msg.format(
                    'rel', version_data.get('rel'), version.links[0].rel))
            if version.status.lower() != version_data.get('status').lower():
                errors.append(self.error_msg.format(
                    'status', version_data.get('status').lower(),
                    version.status.lower()))

        # Allows the full error list to be returned if it is larger than normal
        self.assertEqual.im_class.maxDiff = None

        self.assertListEqual(
            errors, [], msg=('Unexpected errors received. Expected: No errors '
                             'Received: {0}').format(errors))
コード例 #2
0
class VersionsSmoke(ImagesFixture):
    @data_driven_test(ImagesDatasetListGenerator.Versions())
    def ddtest_list_versions(self, url_addition):
        """
        @summary: List all versions

        @param url_addition: Paremter being passed to the list versions request
        @type url_addition: Dictonary

        1) List all versions passing in each url addition
        2) Verify that the response code is 300
        """

        resp = self.images.client.list_versions(url_addition)
        self.assertEqual(
            resp.status_code, 300,
            Messages.STATUS_CODE_MSG.format(300, resp.status_code))