def _Manifest(self, digest, layers=None, config_layer=None):
     if layers is None:
         fs_layers = []
     else:
         fs_layers = [models.FSLayer(blob_sum=x) for x in layers]
     fname = os.path.join(self.content_dir, digest)
     open(fname, "w")
     m = models.Manifest(digest=digest, schema_version=2,
                         fs_layers=fs_layers, config_layer=config_layer)
     m._storage_path = fname
     return m
Esempio n. 2
0
    def test_unit_key(self):
        """
        Assert correct operation of the unit_key property.
        """
        digest = 'sha256:6c3c624b58dbbcd3c0dd82b4c53f04194d1247c6eebdaab7c610cf7d66709b3b'
        fs_layers = [models.FSLayer(blob_sum='rsum:jsf')]
        schema_version = 1
        manifest = models.Manifest(digest=digest,
                                   fs_layers=fs_layers,
                                   schema_version=schema_version)

        unit_key = manifest.unit_key

        self.assertEqual(unit_key, {'digest': digest})
Esempio n. 3
0
    def test_save_bad_schema(self):
        """
        Assert correct operation of the save() method with an invalid (i.e., != 1) schema
        version.
        """
        name = 'name'
        tag = 'tag'
        digest = 'sha256:6c3c624b58dbbcd3c0dd82b4c53f04194d1247c6eebdaab7c610cf7d66709b3b'
        fs_layers = [models.FSLayer(blob_sum='rsum:jsf')]
        schema_version = math.pi
        manifest = models.Manifest(name=name,
                                   tag=tag,
                                   digest=digest,
                                   fs_layers=fs_layers,
                                   schema_version=schema_version)

        self.assertRaises(ValueError, manifest.save)
Esempio n. 4
0
    def test___init__(self):
        """
        Assert correct operation of the __init__() method.
        """
        digest = 'sha256:6c3c624b58dbbcd3c0dd82b4c53f04194d1247c6eebdaab7c610cf7d66709b3b'
        fs_layers = [models.FSLayer(blob_sum='rsum:jsf')]
        schema_version = 2
        config_layer = 'sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef'

        m = models.Manifest(digest=digest,
                            fs_layers=fs_layers,
                            schema_version=schema_version,
                            config_layer=config_layer)

        self.assertEqual(m.digest, digest)
        self.assertEqual(m.fs_layers, fs_layers)
        self.assertEqual(m.schema_version, schema_version)
        self.assertEqual(m.config_layer, config_layer)
Esempio n. 5
0
    def test___init__(self):
        """
        Assert correct operation of the __init__() method.
        """
        name = 'name'
        tag = 'tag'
        digest = 'sha256:6c3c624b58dbbcd3c0dd82b4c53f04194d1247c6eebdaab7c610cf7d66709b3b'
        fs_layers = [models.FSLayer(blob_sum='rsum:jsf')]
        schema_version = 1

        m = models.Manifest(digest=digest,
                            name=name,
                            tag=tag,
                            fs_layers=fs_layers,
                            schema_version=schema_version)

        self.assertEqual(m.name, name)
        self.assertEqual(m.tag, tag)
        self.assertEqual(m.digest, digest)
        self.assertEqual(m.fs_layers, fs_layers)
        self.assertEqual(m.schema_version, schema_version)