Home > testing > unit_tests > importExportTests.m

importExportTests

PURPOSE ^

run this test case with the command

SYNOPSIS ^

function tests = importExportTests

DESCRIPTION ^

run this test case with the command
results = runtests('importExportTests.m')

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 %run this test case with the command
0002 %results = runtests('importExportTests.m')
0003 function tests = importExportTests
0004 tests = functiontests(localfunctions);
0005 end
0006 
0007 function testExcelImport(testCase)
0008 sourceDir=fileparts(fileparts(fileparts(which(mfilename))));
0009 excelFile=fullfile(sourceDir,'tutorial','empty.xlsx');
0010 %%Prepare test results, uncomment and run when new reference is needed
0011 % modelExcel=importExcelModel(excelFile);
0012 % sbmlFile=fullfile(sourceDir,'tutorial','empty.xml');
0013 % modelSBML=importModel(sbmlFile);
0014 % save(fullfile(sourceDir,'testing','unit_tests','test_data','importExportResults.mat'),'modelExcel','modelSBML');
0015 evalc('model=importExcelModel(excelFile)'); % Repress warnings
0016 load(fullfile(sourceDir,'testing','unit_tests','test_data','importExportResults.mat'), 'modelExcel');
0017 verifyEqual(testCase,model,modelExcel)
0018 end
0019 
0020 function testSBMLImport(testCase)
0021 sourceDir=fileparts(fileparts(fileparts(which(mfilename))));
0022 sbmlFile=fullfile(sourceDir,'tutorial','empty.xml');
0023 evalc('model=importModel(sbmlFile)'); % Repress warnings
0024 load(fullfile(sourceDir,'testing','unit_tests','test_data','importExportResults.mat'), 'modelSBML');
0025 verifyEqual(testCase,model,modelSBML)
0026 end
0027 
0028 function testYAMLimport(testCase)
0029 sourceDir=fileparts(fileparts(fileparts(which(mfilename))));
0030 yamlFile=fullfile(sourceDir,'tutorial','empty.yml');
0031 evalc('model=readYAMLmodel(yamlFile)'); % Repress warnings
0032 load(fullfile(sourceDir,'testing','unit_tests','test_data','importExportResults.mat'), 'modelYAML');
0033 verifyEqual(testCase,model,modelYAML)
0034 end
0035 
0036 function testExcelExport(testCase)
0037 sourceDir=fileparts(fileparts(fileparts(which(mfilename))));
0038 load(fullfile(sourceDir,'testing','unit_tests','test_data','ecoli_textbook.mat'), 'model');
0039 exportToExcelFormat(model,fullfile(sourceDir,'testing','unit_tests','test_data','_test.xlsx'));
0040 %File will not be exactly equal as it contains the current date and time,
0041 %so md5 or similar would not work. Just check whether file is reasonably
0042 %sized.
0043 s = dir(fullfile(sourceDir,'testing','unit_tests','test_data','_test.xlsx'));         
0044 filesize = s.bytes;
0045 verifyTrue(testCase,filesize>17000);
0046 delete(fullfile(sourceDir,'testing','unit_tests','test_data','_test.xlsx'));
0047 end
0048 
0049 function testSBMLExport(testCase)
0050 sourceDir=fileparts(fileparts(fileparts(which(mfilename))));
0051 load(fullfile(sourceDir,'testing','unit_tests','test_data','ecoli_textbook.mat'), 'model');
0052 evalc('exportModel(model,fullfile(sourceDir,''testing'',''unit_tests'',''test_data'',''_test.xml''))');
0053 %File will not be exactly equal as it contains the current date and time,
0054 %so md5 or similar would not work. Just check whether file is reasonably
0055 %sized.
0056 s = dir(fullfile(sourceDir,'testing','unit_tests','test_data','_test.xml'));         
0057 filesize = s.bytes;
0058 verifyTrue(testCase,filesize>18500);
0059 delete(fullfile(sourceDir,'testing','unit_tests','test_data','_test.xml'));
0060 end
0061 
0062 function testYAMLexport(testCase)
0063 sourceDir=fileparts(fileparts(fileparts(which(mfilename))));
0064 load(fullfile(sourceDir,'tutorial','empty.mat'), 'emptyModel');
0065 evalc('writeYAMLmodel(emptyModel,fullfile(sourceDir,''testing'',''unit_tests'',''test_data'',''_test.yml''))');
0066 %File will not be exactly equal as it contains the current date and time,
0067 %so md5 or similar would not work. Just check whether file is reasonably
0068 %sized.
0069 s = dir(fullfile(sourceDir,'testing','unit_tests','test_data','_test.yml'));         
0070 filesize = s.bytes;
0071 verifyTrue(testCase,filesize>1290);
0072 delete(fullfile(sourceDir,'testing','unit_tests','test_data','_test.yml'));
0073 end

Generated by m2html © 2005