[3917] | 1 | """Automatic verification that the ANUGA code validates against the okushiri |
---|
| 2 | dataset as expected. See anuga_validation/okushiri_2005 for more details |
---|
| 3 | """ |
---|
| 4 | |
---|
[3919] | 5 | import unittest |
---|
[3917] | 6 | import os |
---|
| 7 | |
---|
| 8 | |
---|
[3919] | 9 | class Test_Okushiri(unittest.TestCase): |
---|
| 10 | def setUp(self): |
---|
[4781] | 11 | |
---|
[3919] | 12 | # Remove garbage |
---|
| 13 | for file in os.listdir('.'): |
---|
| 14 | if file.endswith('.stdout') or\ |
---|
[6707] | 15 | file.endswith('.sww') or\ |
---|
| 16 | file.endswith('.msh'): |
---|
[3919] | 17 | os.remove(file) |
---|
| 18 | |
---|
[6707] | 19 | |
---|
[4783] | 20 | def tearDown(self): |
---|
| 21 | pass |
---|
[3917] | 22 | |
---|
[4783] | 23 | def test_that_output_is_as_expected(self): |
---|
[6706] | 24 | """Test that ANUGA replicates physics of the Okushiri Island |
---|
| 25 | wave tank experiment |
---|
| 26 | """ |
---|
[5183] | 27 | |
---|
[3919] | 28 | #print |
---|
| 29 | s = 'create_okushiri.py' |
---|
| 30 | #print s |
---|
| 31 | res = os.system('python %s > create_okushiri.stdout' %s) |
---|
| 32 | assert res == 0 |
---|
[3917] | 33 | |
---|
[3919] | 34 | s = 'run_okushiri.py' |
---|
| 35 | #print s |
---|
| 36 | res = os.system('python %s > run_okushiri.stdout' %s) |
---|
| 37 | assert res == 0 |
---|
[5183] | 38 | |
---|
| 39 | |
---|
[3919] | 40 | s = 'compare_timeseries_with_measures.py' |
---|
| 41 | #print s |
---|
| 42 | res = os.system('python %s > compare_timeseries_with_measures.stdout'\ |
---|
| 43 | %s) |
---|
| 44 | assert res == 0 |
---|
| 45 | |
---|
[6704] | 46 | |
---|
| 47 | def test_caching_of_set_quantity(self): |
---|
| 48 | """Test that caching of set_quantity works |
---|
| 49 | """ |
---|
[6732] | 50 | |
---|
| 51 | s = 'create_okushiri.py' |
---|
| 52 | res = os.system('python %s > create_okushiri_for_caching.stdout' %s) |
---|
| 53 | assert res == 0 |
---|
[6704] | 54 | |
---|
[6732] | 55 | |
---|
[6704] | 56 | s = 'test_caching_of_set_quantity.py' |
---|
| 57 | res = os.system('python %s > test_caching_of_set_quantity.stdout' %s) |
---|
| 58 | assert res == 0 |
---|
| 59 | |
---|
| 60 | |
---|
| 61 | |
---|
[4783] | 62 | def manual_test_that_output_is_as_expected(self): |
---|
| 63 | from run_okushiri import main |
---|
| 64 | from create_okushiri import create_mesh |
---|
[3919] | 65 | |
---|
[4783] | 66 | # Note, this has not been tested when code is failing. |
---|
| 67 | # Next step, use the parrameter elevation_in_mesh |
---|
| 68 | # and only run create_okishiri once for speed. |
---|
| 69 | |
---|
| 70 | res = create_mesh() |
---|
| 71 | assert res == None |
---|
| 72 | |
---|
| 73 | res = main() |
---|
| 74 | assert res == None |
---|
| 75 | |
---|
| 76 | s = 'compare_timeseries_with_measures.py' |
---|
| 77 | #print s |
---|
| 78 | res = os.system('python %s > compare_timeseries_with_measures.stdout'\ |
---|
| 79 | %s) |
---|
| 80 | assert res == 0 |
---|
| 81 | |
---|
[3919] | 82 | |
---|
| 83 | #------------------------------------------------------------- |
---|
| 84 | if __name__ == "__main__": |
---|
[6704] | 85 | suite = unittest.makeSuite(Test_Okushiri, 'test') |
---|
[3919] | 86 | runner = unittest.TextTestRunner(verbosity=2) |
---|
| 87 | runner.run(suite) |
---|