1 | """ |
---|
2 | Unit tests for the sas_gen |
---|
3 | """ |
---|
4 | |
---|
5 | import os.path |
---|
6 | import warnings |
---|
7 | warnings.simplefilter("ignore") |
---|
8 | |
---|
9 | import unittest |
---|
10 | from sas.sascalc.calculator import sas_gen |
---|
11 | |
---|
12 | |
---|
13 | def find(filename): |
---|
14 | return os.path.join(os.path.dirname(__file__), filename) |
---|
15 | |
---|
16 | |
---|
17 | class sas_gen_test(unittest.TestCase): |
---|
18 | |
---|
19 | def setUp(self): |
---|
20 | self.sldloader = sas_gen.SLDReader() |
---|
21 | self.pdbloader = sas_gen.PDBReader() |
---|
22 | self.omfloader = sas_gen.OMFReader() |
---|
23 | |
---|
24 | def test_sldreader(self): |
---|
25 | """ |
---|
26 | Test .sld file loaded |
---|
27 | """ |
---|
28 | f = self.sldloader.read(find("sld_file.sld")) |
---|
29 | self.assertEqual(f.pos_x[0], -40.5) |
---|
30 | self.assertEqual(f.pos_y[0], -13.5) |
---|
31 | self.assertEqual(f.pos_z[0], -13.5) |
---|
32 | |
---|
33 | def test_pdbreader(self): |
---|
34 | """ |
---|
35 | Test .pdb file loaded |
---|
36 | """ |
---|
37 | f = self.pdbloader.read(find("c60.pdb")) |
---|
38 | self.assertEqual(f.pos_x[0], -0.733) |
---|
39 | self.assertEqual(f.pos_y[0], -1.008) |
---|
40 | self.assertEqual(f.pos_z[0], 3.326) |
---|
41 | |
---|
42 | def test_omfreader(self): |
---|
43 | """ |
---|
44 | Test .omf file loaded |
---|
45 | """ |
---|
46 | f = self.omfloader.read(find("A_Raw_Example-1.omf")) |
---|
47 | output = sas_gen.OMF2SLD() |
---|
48 | output.set_data(f) |
---|
49 | self.assertEqual(f.mx[0], 0) |
---|
50 | self.assertEqual(f.my[0], 0) |
---|
51 | self.assertEqual(f.mz[0], 0) |
---|
52 | self.assertEqual(output.pos_x[0], 0.0) |
---|
53 | self.assertEqual(output.pos_y[0], 0.0) |
---|
54 | self.assertEqual(output.pos_z[0], 0.0) |
---|
55 | |
---|
56 | |
---|
57 | if __name__ == '__main__': |
---|
58 | unittest.main() |
---|
59 | |
---|