コード例 #1
0
ファイル: comparator.py プロジェクト: kyle-long/pyshelf
    def compare(self, resource_url, bucket_name):
        identity = ResourceIdentity(resource_url)
        cloud_portal = self.factory.create_cloud_portal(bucket_name)
        cloud_metadata = cloud_portal.load(identity.cloud_metadata)
        if not cloud_metadata:
            self.fail("Failed to find metadata in cloud for {0}".format(identity.cloud_metadata))
        # Make extra sure our data will show up
        self.es_connection.indices.refresh(index=self.index)
        metadata = Metadata.get(index=self.index, using=self.es_connection, id=identity.search, ignore=404)
        if not metadata:
            self.test.fail("Failed to find metadata in search for {0}".format(identity.search))

        metadata = self._map_es_metadata(metadata)
        self.test.asserts.json_equals(cloud_metadata, metadata)
コード例 #2
0
    def _get_metadata(self, key):
        """
            Attempts to get existing metadata and creates one if it does not exist.

            Args:
                key(string): Unique key that represents the unique id of the metadata document.

            Returns:
                pyshelf.search.metadata.Metadata
        """
        meta_doc = Metadata.get(id=key, index=self.index, using=self.connection, ignore=404)

        if not meta_doc:
            meta_doc = Metadata()
            meta_doc.meta.id = key
            meta_doc.meta.index = self.index

        return meta_doc
コード例 #3
0
    def compare(self, resource_url):
        identity = ResourceIdentity(resource_url)
        cloud_portal = self.factory.create_cloud_portal(identity.bucket_name)
        cloud_metadata = cloud_portal.load(identity.cloud_metadata)
        if not cloud_metadata:
            self.fail("Failed to find metadata in cloud for {0}".format(
                identity.cloud_metadata))
        # Make extra sure our data will show up
        self.es_connection.indices.refresh(index=self.index)
        metadata = Metadata.get(index=self.index,
                                using=self.es_connection,
                                id=identity.search,
                                ignore=404)
        if not metadata:
            self.test.fail("Failed to find metadata in search for {0}".format(
                identity.search))

        metadata = self._map_es_metadata(metadata)
        self.test.asserts.json_equals(cloud_metadata, metadata)
コード例 #4
0
 def get_metadata(self, id):
     return Metadata.get(index=self.index, using=self.connection, id=id, ignore=404)