def test_unique_asset_id_reference_from_fields(self):
     """Make sure uuid generator produces accurate strings"""
     ret = utils.unique_asset_id_reference_from_fields(
         'OHIAMAHASH',
         'SNAILJUICE',
         'text/rtf'
     )
     self.assertEqual(ret, 'OHIAMAHASHSNAILJUICEtext__rtf')
Example #2
0
 def transform(args):
     data = args.infile.read()
     data = json.loads(data)
     file_hash = data["file"]["hash"]
     assets = []
     file_copy = copy.deepcopy(data)
     file_copy['metadata'] = file_copy.get('metadata', {})
     del file_copy['assets']
     for asset in data['assets']:
         subname = asset['asset']['subname']
         mimetype = asset['asset']['mimetype']
         id = unique_asset_id_reference_from_fields(file_hash, subname, mimetype)
         a = {'id': id, 'file': file_copy}
         asset['metadata'] = asset.get('metadata', {})
         a.update(asset)
         assets.append(a)
     for asset in assets:
         print json.dumps({'index': {'_id': asset['id']}})
         print json.dumps(asset)
Example #3
0
 def save(self, *args, **kwargs):
   self.slug = unique_asset_id_reference_from_fields(self.file.hash, self.subname, self.mimetype)
   super(AssetReference, self).save(*args, **kwargs)
Example #4
0
    def test_unique_asset_id_reference_from_fields(self):
        """Make sure uuid generator produces accurate strings"""

        ret = utils.unique_asset_id_reference_from_fields(
            'OHIAMAHASH', 'SNAILJUICE', 'text/rtf')
        self.assertEqual(ret, 'OHIAMAHASHSNAILJUICEtext__rtf')
Example #5
0
 def save(self, *args, **kwargs):
     self.slug = unique_asset_id_reference_from_fields(
         self.file.hash, self.subname, self.mimetype)
     super(AssetReference, self).save(*args, **kwargs)