def repair_bag_techmd(bag, repairer, dryrun): media_files_filenames = set([os.path.basename(path) for path in bag.media_filepaths]) updated_json = [] for filename in bag.metadata_files: json_path = os.path.join(bag.path, filename) json = ami_json(filepath = json_path) media_filepath = os.path.join(os.path.split(json.path)[0], json.dict["asset"]["referenceFilename"]) json.set_mediafilepath(media_filepath) try: json.check_techmd_values() except: json.repair_techmd() updated_json.append(json.filename) if not dryrun: json.write_json(os.path.split(json_path)[0]) if updated_json: updateable_bag = Repairable_Bag(bag.path, repairer = repairer, dryrun = dryrun) updateable_bag.add_premisevent(process = "Repair Metadata", msg = "Regenerated tech md fields with MediaInfo: {}".format( ", ".join(updated_json)), outcome = "Pass", sw_agent = sys._getframe().f_code.co_name) updateable_bag.update_hashes(filename_pattern = r"json")
def test_validate_valid_json(self): pm_json = aj.ami_json(filepath = pm_json_path) with self.assertLogs('ami_md.ami_json', 'WARN') as cm: valid = pm_json.validate_json() self.assertTrue(valid) self.assertEqual(cm.output, ['WARNING:ami_md.ami_json:Cannot check technical metadata values against media file without location of the described media file.'])
def test_repair_techfn(self): pm_json = aj.ami_json(filepath=pm_json_path) pm_json.dict['technical']['filename'] = pm_mov_filename self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.check_techfn) pm_json.repair_techfn() self.assertTrue(pm_json.validate_json()) self.assertTrue(pm_json.check_techfn)
def test_validate_techfn_media_filepath_disagreement(self): pm_json = aj.ami_json(filepath = pm_json_path, media_filepath = pm_mov_path) bad_mov_filename = pm_mov_filename.replace('2', '3') pm_json.dict['asset']['referenceFilename'] = bad_mov_filename pm_json.dict['technical']['filename'] = bad_mov_filename.replace('.mov', '') self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.compare_techfn_media_filename)
def test_techmd_value_check_disagreement(self): pm_json = aj.ami_json(filepath = pm_json_path, media_filepath = pm_mov_path) pm_json.set_media_file() pm_json.media_file.duration_milli = 200 self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.check_md_value, field = 'durationMilli.measure', mapped_field = 'duration_milli')
def test_validate_valid_json(self): pm_json = aj.ami_json(filepath=pm_json_path) with self.assertLogs('ami_md.ami_json', 'WARN') as cm: valid = pm_json.validate_json() self.assertTrue(valid) self.assertEqual(cm.output, [ 'WARNING:ami_md.ami_json:Cannot check technical metadata values against media file without location of the described media file.' ])
def test_repair_techfn(self): pm_json = aj.ami_json(filepath = pm_json_path) pm_json.dict['technical']['filename'] = pm_mov_filename self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.check_techfn) pm_json.repair_techfn() self.assertTrue(pm_json.validate_json()) self.assertTrue(pm_json.check_techfn)
def convert_amiExcelToJSON(self, json_directory, schema_version="x.0.0", filepaths=None): """ Convert all rows in an Excel sheet into JSON files with normalized data. Filename is based on described file's name. Keyword arguments: sheetname -- name of the sheet to convert (self.pres_sheetname or self.edit_sheetname) json_directory -- path to output directory for json files """ self.normalize_sheet_values() json_directory = os.path.abspath(json_directory) df = self.sheet_values if filepaths: for filepath in filepaths: media_filename = os.path.splitext( os.path.basename(filepath))[0] try: row = df[df["technical.filename"] == os.path.splitext( media_filename)[0]] except: raise_excelerror( "Excel sheet does not have a record for {}".format( media_filename)) row_dict = row.squeeze().to_dict() row_dict["asset.referenceFilename"] = media_filename json_tree = ami_json.ami_json( flat_dict=row_dict, filepath=filepath, load=False, media_filepath=os.path.splitext(filepath)[0]) json_tree.repair_techmd() json_tree.write_json(json_directory) else: for (index, row) in self.sheet_values.iterrows(): json_tree = ami_json.ami_json(flat_dict=row.to_dict()) json_tree.write_json(json_directory)
def test_repair_reffn(self): pm_json = aj.ami_json(filepath = pm_json_path) pm_json.dict['asset']['referenceFilename'] = pm_mov_filename[:-6] self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.check_reffn) pm_json.repair_reffn() self.assertTrue(pm_json.validate_json()) self.assertTrue(pm_json.check_reffn()) self.assertTrue(pm_json.compare_techfn_reffn())
def test_repair_reffn(self): pm_json = aj.ami_json(filepath=pm_json_path) pm_json.dict['asset']['referenceFilename'] = pm_mov_filename[:-6] self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.check_reffn) pm_json.repair_reffn() self.assertTrue(pm_json.validate_json()) self.assertTrue(pm_json.check_reffn()) self.assertTrue(pm_json.compare_techfn_reffn())
def test_validate_file_missing_duration(self): pm_json = aj.ami_json(filepath = pm_json_path, media_filepath = pm_mov_path) pm_json.set_media_file() # duration_human is a formatted object that might fail to be created del pm_json.media_file.duration_human self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.check_md_value, field = 'durationHuman', mapped_field = 'duration_human')
def test_validate_warn_date_disagreement(self): # Dates are relatively unreliable, but at least useful to look out for pm_json = aj.ami_json(filepath = pm_json_path, media_filepath = pm_mov_path) with self.assertLogs('ami_md.ami_json', 'WARN') as cm: valid_md = pm_json.validate_json() self.assertTrue(valid_md) expected_msg = 'WARNING:ami_md.ami_json:dateCreated in JSON and from file disagree. ' expected_msg += 'JSON: 2016-09-14, From file:' self.assertTrue(expected_msg in cm.output[0])
def test_validate_techfn_media_filepath_disagreement(self): pm_json = aj.ami_json(filepath=pm_json_path, media_filepath=pm_mov_path) bad_mov_filename = pm_mov_filename.replace('2', '3') pm_json.dict['asset']['referenceFilename'] = bad_mov_filename pm_json.dict['technical']['filename'] = bad_mov_filename.replace( '.mov', '') self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.compare_techfn_media_filename)
def test_techmd_value_check_disagreement(self): pm_json = aj.ami_json(filepath=pm_json_path, media_filepath=pm_mov_path) pm_json.set_media_file() pm_json.media_file.duration_milli = 200 self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.check_md_value, field='durationMilli.measure', mapped_field='duration_milli')
def test_validate_warn_date_disagreement(self): # Dates are relatively unreliable, but at least useful to look out for pm_json = aj.ami_json(filepath=pm_json_path, media_filepath=pm_mov_path) with self.assertLogs('ami_md.ami_json', 'WARN') as cm: valid_md = pm_json.validate_json() self.assertTrue(valid_md) expected_msg = 'WARNING:ami_md.ami_json:dateCreated in JSON and from file disagree. ' expected_msg += 'JSON: 2016-09-14, From file:' self.assertTrue(expected_msg in cm.output[0])
def test_unrepairable_techfn(self): pm_json = aj.ami_json(filepath = pm_json_path) pm_json.dict['technical']['filename'] = pm_mov_filename[:-6] self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.check_techfn) with self.assertLogs('ami_md.ami_json', 'ERROR') as cm: pm_json.repair_techfn() self.assertEqual(cm.output, ['ERROR:ami_md.ami_json:Valid technical.filename could not be extracted from myd_263524_v01_']) self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.check_techfn)
def test_validate_file_missing_duration(self): pm_json = aj.ami_json(filepath=pm_json_path, media_filepath=pm_mov_path) pm_json.set_media_file() # duration_human is a formatted object that might fail to be created del pm_json.media_file.duration_human self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.check_md_value, field='durationHuman', mapped_field='duration_human')
def test_unrepairable_techfn(self): pm_json = aj.ami_json(filepath=pm_json_path) pm_json.dict['technical']['filename'] = pm_mov_filename[:-6] self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.check_techfn) with self.assertLogs('ami_md.ami_json', 'ERROR') as cm: pm_json.repair_techfn() self.assertEqual(cm.output, [ 'ERROR:ami_md.ami_json:Valid technical.filename could not be extracted from myd_263524_v01_' ]) self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.check_techfn)
def test_bad_techfn(self): pm_json = aj.ami_json(filepath = pm_json_path) pm_json.dict['technical']['filename'] = pm_mov_filename.replace('2', '3')[:-3] self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.check_techfn) with self.assertLogs('ami_md.ami_json', 'WARN') as cm: pm_json.repair_techfn() self.assertEqual(cm.output, ['WARNING:ami_md.ami_json:Extracted technical filename does not match referenceFilename value.']) self.assertTrue(pm_json.check_techfn()) self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.compare_techfn_reffn)
def test_unrepairable_reffn(self): pm_json = aj.ami_json(filepath = pm_json_path) pm_json.dict['asset']['referenceFilename'] = pm_mov_filename[:-6] pm_json.dict['technical']['filename'] = pm_mov_filename[:-6] self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.check_reffn) with self.assertLogs('ami_md.ami_json', 'ERROR') as cm: pm_json.repair_reffn() self.assertEqual(cm.output, ['ERROR:ami_md.ami_json:Valid asset.referenceFilename cannot be created from technical fields: myd_263524_v01_, mov']) self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.check_reffn)
def test_validate_techmd_multiple_disagreement(self): pm_json = aj.ami_json(filepath=pm_json_path, media_filepath=pm_mov_path) pm_json.set_media_file() pm_json.media_file.duration_milli = 200 pm_json.media_file.video_codec = 200 with self.assertLogs('ami_md.ami_json', 'ERROR') as cm: valid_md = pm_json.validate_json() self.assertFalse(valid_md) expected_msg = 'ERROR:ami_md.ami_json:Error in JSON metadata: ' expected_msg += 'Incorrect value for durationMilli.measure. Expected: 201, Found: 200. ' expected_msg += 'Incorrect value for videoCodec. Expected: v210, Found: 200.' self.assertTrue(expected_msg in cm.output)
def test_validate_techmd_multiple_disagreement(self): pm_json = aj.ami_json(filepath = pm_json_path, media_filepath = pm_mov_path) pm_json.set_media_file() pm_json.media_file.duration_milli = 200 pm_json.media_file.video_codec = 200 with self.assertLogs('ami_md.ami_json', 'ERROR') as cm: valid_md = pm_json.validate_json() self.assertFalse(valid_md) expected_msg = 'ERROR:ami_md.ami_json:Error in JSON metadata: ' expected_msg += 'Incorrect value for durationMilli.measure. Expected: 201, Found: 200. ' expected_msg += 'Incorrect value for videoCodec. Expected: v210, Found: 200.' self.assertTrue(expected_msg in cm.output)
def test_bad_techfn_with_media_filepath(self): pm_json = aj.ami_json(filepath = pm_json_path, media_filepath = pm_mov_path) pm_json.dict['technical']['filename'] = pm_mov_filename.replace('2', '3')[:-3] self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.check_techfn) with self.assertLogs('ami_md.ami_json', 'ERROR') as cm: pm_json.repair_techfn() self.assertEqual(cm.output, ['ERROR:ami_md.ami_json:Extracted technical filename does not match provide media filename.']) self.assertRaises(aj.AMIJSONError, pm_json.check_techfn) self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.compare_techfn_media_filename)
def test_unrepairable_reffn(self): pm_json = aj.ami_json(filepath=pm_json_path) pm_json.dict['asset']['referenceFilename'] = pm_mov_filename[:-6] pm_json.dict['technical']['filename'] = pm_mov_filename[:-6] self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.check_reffn) with self.assertLogs('ami_md.ami_json', 'ERROR') as cm: pm_json.repair_reffn() self.assertEqual(cm.output, [ 'ERROR:ami_md.ami_json:Valid asset.referenceFilename cannot be created from technical fields: myd_263524_v01_, mov' ]) self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.check_reffn)
def main(): parser = _make_parser() args = parser.parse_args() md = pd.read_csv(args.input, dtype=dtypes) md = md.dropna(axis=1, how="all") md = md.drop(['asset.fileExt'], axis=1) json_directory = os.path.abspath(args.output) for (index, row) in md.iterrows(): json_tree = aj.ami_json(flat_dict=row.to_dict(), schema_version=args.schema) json_tree.write_json(json_directory, indent=4)
def test_bad_techfn(self): pm_json = aj.ami_json(filepath=pm_json_path) pm_json.dict['technical']['filename'] = pm_mov_filename.replace( '2', '3')[:-3] self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.check_techfn) with self.assertLogs('ami_md.ami_json', 'WARN') as cm: pm_json.repair_techfn() self.assertEqual(cm.output, [ 'WARNING:ami_md.ami_json:Extracted technical filename does not match referenceFilename value.' ]) self.assertTrue(pm_json.check_techfn()) self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.compare_techfn_reffn)
def main(): parser = _make_parser() args = parser.parse_args() md = pd.read_csv(args.input, dtype = dtypes, encoding="mac_roman") md = md.dropna(axis = 1, how = "all") md = md.drop(['asset.fileExt'], axis = 1) json_directory = os.path.abspath(args.output) for (index, row) in md.iterrows(): json_tree = aj.ami_json(flat_dict = row.to_dict(), schema_version = args.schema) json_tree.write_json(json_directory, indent = 4)
def set_metadata_json(self): self.metadata_files = [filename for filename in self.data_files if os.path.splitext(filename)[1] == ".json"] self.media_files_md = [] for filename in self.metadata_files: json = aj.ami_json(filepath = os.path.join(self.path, filename)) filename = json.dict["technical"]["filename"] ext = json.dict["technical"]["extension"] self.media_files_md.append(filename + '.' + ext) self.media_files_md = set(self.media_files_md) return
def convert_amiExcelToJSON(self, json_directory, schema_version = "x.0.0", filepaths = None): """ Convert all rows in an Excel sheet into JSON files with normalized data. Filename is based on described file's name. Keyword arguments: sheetname -- name of the sheet to convert (self.pres_sheetname or self.edit_sheetname) json_directory -- path to output directory for json files """ self.normalize_sheet_values() json_directory = os.path.abspath(json_directory) df = self.sheet_values if filepaths: for filepath in filepaths: media_filename = os.path.splitext(os.path.basename(filepath))[0] try: row = df[df["technical.filename"] == os.path.splitext(media_filename)[0]] except: raise_excelerror("Excel sheet does not have a record for {}".format(media_filename)) row_dict = row.squeeze().to_dict() row_dict["asset.referenceFilename"] = media_filename json_tree = ami_json.ami_json(flat_dict = row_dict, filepath = filepath, load = False, media_filepath = os.path.splitext(filepath)[0]) json_tree.repair_techmd() json_tree.write_json(json_directory) else: for (index, row) in self.sheet_values.iterrows(): json_tree = ami_json.ami_json(flat_dict = row.to_dict()) json_tree.write_json(json_directory)
def test_bad_techfn_with_media_filepath(self): pm_json = aj.ami_json(filepath=pm_json_path, media_filepath=pm_mov_path) pm_json.dict['technical']['filename'] = pm_mov_filename.replace( '2', '3')[:-3] self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.check_techfn) with self.assertLogs('ami_md.ami_json', 'ERROR') as cm: pm_json.repair_techfn() self.assertEqual(cm.output, [ 'ERROR:ami_md.ami_json:Extracted technical filename does not match provide media filename.' ]) self.assertRaises(aj.AMIJSONError, pm_json.check_techfn) self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.compare_techfn_media_filename)
def set_metadata_json(self): self.metadata_files = [ filename for filename in self.data_files if os.path.splitext(filename)[1] == ".json" ] self.media_files_md = [] for filename in self.metadata_files: json = aj.ami_json(filepath=os.path.join(self.path, filename)) filename = json.dict["technical"]["filename"] ext = json.dict["technical"]["extension"] self.media_files_md.append(filename + '.' + ext) self.media_files_md = set(self.media_files_md) return
def check_metadata_json(self): if not self.metadata_files: raise ami_bagError("JSON bag does not contain any files with json extension") bad_json = [] for filename in self.metadata_files: json_filepath = os.path.join(self.path, filename) json = aj.ami_json(filepath = json_filepath) ext = json.dict['technical']['extension'] json.set_mediafilepath(json_filepath.replace('json', ext)) try: json.validate_json() except: bad_json.append(filename) if bad_json: raise ami_bagError("JSON files contain formatting errors") return True
def repair_bag_filenamemd(bag, repairer, dryrun): media_files_filenames = set([os.path.basename(path) for path in bag.media_filepaths]) repaired_fn = [] for filename in bag.metadata_files: repaired = False json_path = os.path.join(bag.path, filename) json = ami_json(filepath = json_path) try: json.check_techfn() except: if json.repair_techfn(): repaired = True try: json.check_reffn() except: if json.repair_reffn(): repaired = True reffn = json.dict["asset"]["referenceFilename"] techfn = json.dict["technical"]["filename"] + '.' + json.dict["technical"]["extension"] if repaired: if (reffn in media_files_filenames and techfn in media_files_filenames): if not dryrun: json.write_json(os.path.split(json_path)[0]) repaired_fn.append(json.filename) else: LOGGER.error("Filenames still not great, not writing changes to file for {}".format( filename)) if repaired_fn: updateable_bag = Repairable_Bag(bag.path, repairer = repairer, dryrun = dryrun) updateable_bag.add_premisevent(process = "Repair Metadata", msg = "Repaired filename fields: {}".format( ", ".join(repaired_fn)), outcome = "Pass", sw_agent = sys._getframe().f_code.co_name) updateable_bag.update_hashes(filename_pattern = r"json")
def check_metadata_json(self): if not self.metadata_files: self.raise_bagerror( "JSON bag does not contain any files with json extension") bad_json = [] for filename in self.metadata_files: json_filepath = os.path.join(self.path, filename) json = aj.ami_json(filepath=json_filepath) ext = json.dict['technical']['extension'] json.set_mediafilepath(json_filepath.replace('json', ext)) try: json.validate_json() except: bad_json.append(filename) if bad_json: self.raise_bagerror("JSON files contain formatting errors") return True
def test_validate_valid_json_with_media_file(self): pm_json = aj.ami_json(filepath = pm_json_path, media_filepath = pm_mov_path) self.assertTrue(pm_json.validate_json()) self.assertTrue(isinstance(pm_json.media_file, af.ami_file))
def test_load_json_file(self): pm_json = aj.ami_json(filepath = pm_json_path) self.assertEqual(pm_json.filename, pm_json_filename) self.assertTrue(hasattr(pm_json, 'dict')) self.assertTrue(pm_json.media_format_type == 'video')
def test_validate_md_filename_disagreement(self): pm_json = aj.ami_json(filepath=pm_json_path) pm_json.dict['asset']['referenceFilename'] = pm_mov_filename.replace( '2', '3') self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.compare_techfn_reffn)
def test_validate_bad_ref_filename(self): pm_json = aj.ami_json(filepath=pm_json_path) pm_json.dict['asset']['referenceFilename'] = pm_json.dict['technical'][ 'filename'] self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.check_reffn)
def test_validate_missing_ref_filename(self): pm_json = aj.ami_json(filepath=pm_json_path) pm_json.dict['asset'].pop('referenceFilename', None) self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.check_reffn)
def test_load_json_file(self): pm_json = aj.ami_json(filepath=pm_json_path) self.assertEqual(pm_json.filename, pm_json_filename) self.assertTrue(hasattr(pm_json, 'dict')) self.assertTrue(pm_json.media_format_type == 'video')
def test_validate_missing_tech_filename(self): pm_json = aj.ami_json(filepath = pm_json_path) pm_json.dict['technical'].pop('filename', None) self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.check_techfn)
def test_dont_load_json_file(self): pm_json = aj.ami_json(filepath=pm_json_path, load=False) self.assertFalse(hasattr(pm_json, 'dict'))
def test_validate_missing_ref_filename(self): pm_json = aj.ami_json(filepath = pm_json_path) pm_json.dict['asset'].pop('referenceFilename', None) self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.check_reffn)
def test_validate_bad_ref_filename(self): pm_json = aj.ami_json(filepath = pm_json_path) pm_json.dict['asset']['referenceFilename'] = pm_json.dict['technical']['filename'] self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.check_reffn)
def test_validate_md_filename_disagreement(self): pm_json = aj.ami_json(filepath = pm_json_path) pm_json.dict['asset']['referenceFilename'] = pm_mov_filename.replace('2', '3') self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.compare_techfn_reffn)
def test_validate_missing_techmd_field(self): pm_json = aj.ami_json(filepath=pm_json_path) pm_json.dict['technical'].pop('durationHuman', None) self.assertFalse(pm_json.validate_json()) self.assertFalse(pm_json.valid_techmd_fields) self.assertRaises(aj.AMIJSONError, pm_json.check_techmd_fields)
def test_load_media_filepath(self): pm_json = aj.ami_json(filepath=pm_json_path, media_filepath=pm_mov_path) self.assertTrue(hasattr(pm_json, 'media_filepath'))
def test_load_media_filepath(self): pm_json = aj.ami_json(filepath = pm_json_path, media_filepath = pm_mov_path) self.assertTrue(hasattr(pm_json, 'media_filepath'))
def test_validate_missing_techmd_field(self): pm_json = aj.ami_json(filepath = pm_json_path) pm_json.dict['technical'].pop('durationHuman', None) self.assertFalse(pm_json.validate_json()) self.assertFalse(pm_json.valid_techmd_fields) self.assertRaises(aj.AMIJSONError, pm_json.check_techmd_fields)
def test_dont_load_json_file(self): pm_json = aj.ami_json(filepath = pm_json_path, load = False) self.assertFalse(hasattr(pm_json, 'dict'))
def test_validate_missing_tech_filename(self): pm_json = aj.ami_json(filepath=pm_json_path) pm_json.dict['technical'].pop('filename', None) self.assertFalse(pm_json.validate_json()) self.assertRaises(aj.AMIJSONError, pm_json.check_techfn)
def test_validate_valid_json_with_media_file(self): pm_json = aj.ami_json(filepath=pm_json_path, media_filepath=pm_mov_path) self.assertTrue(pm_json.validate_json()) self.assertTrue(isinstance(pm_json.media_file, af.ami_file))