Commit f39f98b9 authored by Javier Vegas-Regidor's avatar Javier Vegas-Regidor
Browse files

Added more tests

parent 6716bda4
#!/usr/bin/env bash
#SBATCH -n 1
#SBATCH --time 24:00:00
#SBATCH -n 2
#SBATCH --time 72:00:00
#SBATCH --error=job.%J.err
#SBATCH --output=job.%J.out
......
......@@ -78,6 +78,24 @@ class TestUtils(TestCase):
with self.assertRaises(Exception):
Utils.rename_variables('file', {'old_var': 'new'}, rename_dimension=True)
def test_available_cpu_count(self):
Utils.available_cpu_count()
Utils.available_cpu_count()
def test_convert2netcdf4(self):
mock_handler = mock.Mock()
with mock.patch('earthdiagnostics.utils.Utils.openCdf') as opencdf_mock:
with mock.patch('earthdiagnostics.utils.Utils.execute_shell_command') as execute_mock:
with mock.patch('earthdiagnostics.utils.TempFile.get') as tempfile_mock:
with mock.patch('shutil.move'):
tempfile_mock.return_value = 'tempfile'
opencdf_mock.return_value = mock_handler
mock_handler.file_format = 'NETCDF4'
Utils.convert2netcdf4('file', False)
mock_handler.file_format = 'OTHER'
Utils.convert2netcdf4('file2', False)
execute_mock.assert_called_with(['nccopy', '-4', '-d4', '-s', 'file2', 'tempfile'])
mock_handler.file_format = 'NETCDF4'
Utils.convert2netcdf4('file3', True)
execute_mock.assert_called_with(['nccopy', '-4', '-d4', '-s', 'file3', 'tempfile'])
self.assertEqual(execute_mock.call_count, 2)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment