source: nappy/trunk/nappy/unit_tests/test_na_file_4010.py @ 3524

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/nappy/trunk/nappy/unit_tests/test_na_file_4010.py@3524
Revision 3524, 1.4 KB checked in by astephen, 12 years ago (diff)

Fixed, renewed and added tests.

Line 
1"""
2test_na_file_4010.py
3====================
4
5Tests for the na_file_4010.py module.
6
7"""
8
9# Import standard library modules
10import unittest
11import os
12import sys
13
14# Import local modules
15base_dir = os.environ.get("NAPPY_BASE_DIR", "../..")
16sys.path.append(base_dir)
17
18import nappy
19
20class NAFile4010_TestCase(unittest.TestCase):
21
22    def setUp(self):
23        self.infile = os.path.join(base_dir, "data_files", "4010.na")
24        self.outfile = os.path.join(base_dir, "test_outputs", "test_4010.na")
25        self.out_csv = os.path.join(base_dir, "test_outputs", "test_4010.csv")
26        self.fin = nappy.openNAFile(self.infile)
27        self.fin.readData()
28        self.na_dict = self.fin.getNADict()       
29
30    def test_read4010(self):
31        "Tests reading FFI 4010."
32        self.assertEqual(type(self.na_dict), type({1:2}))
33
34    def test_write4010(self):
35        "Tests writing FFI 4010."
36        fobj = nappy.openNAFile(self.outfile, mode="w", na_dict=self.na_dict)           
37        fobj.write()
38        self.failUnless(isinstance(fobj, nappy.na_file.na_file.NAFile))
39
40    def test_writeAnnotatedCSV4010(self):
41        "Tests conversion to NetCDF."
42        fobj = nappy.openNAFile(self.out_csv, mode="w", na_dict=self.na_dict)
43        fobj.write(delimiter=",", float_format="%.2d", annotation=True)
44        self.failUnless(isinstance(fobj, nappy.na_file.na_file.NAFile))
45 
46
47if __name__ ==  "__main__":
48
49    unittest.main()
50
51
Note: See TracBrowser for help on using the repository browser.