def test_fs_read(fix_flow_serde): r1 = utils.fs_read( file_path=fix_flow_serde.filepath + '.json' ) assert r1 == fix_flow_serde.json # Test reading from unreachable file with pytest.raises(IOError): _ = utils.fs_read( file_path='/dev/AlmostCertainlyNotAValidDevice' )
def test_export_flow_version(regress_flow_reg, fix_flow_serde): # Test we can turn a flow snapshot into a json string r1 = versioning.export_flow_version( fix_flow_serde.bucket.identifier, fix_flow_serde.flow.identifier ) assert isinstance(r1, str) # Test writing it to a file r2 = versioning.export_flow_version( fix_flow_serde.bucket.identifier, fix_flow_serde.flow.identifier, file_path=fix_flow_serde.filepath + '_test.json' ) assert isinstance(r2, str) r2l = utils.load(r2) assert isinstance(r2l, dict) assert r2l['snapshotMetadata'].__contains__('flowIdentifier') # read in the file r2f = utils.fs_read(fix_flow_serde.filepath + '_test.json') DeepDiff( r2, r2f, ignore_order=False, verbose_level=2 ) # Test yaml dump r3 = versioning.export_flow_version( fix_flow_serde.bucket.identifier, fix_flow_serde.flow.identifier, mode='yaml' ) assert isinstance(r3, str) r3l = utils.load(r3) assert isinstance(r3l, dict) assert r3l['snapshotMetadata'].__contains__('flowIdentifier')