1 2import testing 3from testing import value_eq,object_eq,text_eq 4 5 6projwfc_in = '''&projwfc 7 prefix = 'pwscf' 8 outdir = 'pwscf_output' 9/ 10''' 11 12 13 14def test_import(): 15 from pwscf_postprocessors import PPInput,generate_pp_input 16 from pwscf_postprocessors import DosInput,generate_dos_input 17 from pwscf_postprocessors import BandsInput,generate_bands_input 18 from pwscf_postprocessors import ProjwfcInput,generate_projwfc_input 19 from pwscf_postprocessors import CpppInput,generate_cppp_input 20 from pwscf_postprocessors import PwexportInput,generate_pwexport_input 21#end def test_import 22 23 24 25def test_empty_init(): 26 from pwscf_postprocessors import PPInput,generate_pp_input 27 from pwscf_postprocessors import DosInput,generate_dos_input 28 from pwscf_postprocessors import BandsInput,generate_bands_input 29 from pwscf_postprocessors import ProjwfcInput,generate_projwfc_input 30 from pwscf_postprocessors import CpppInput,generate_cppp_input 31 from pwscf_postprocessors import PwexportInput,generate_pwexport_input 32 33 ppi = PPInput() 34 ppi = generate_pp_input() 35 36 ppi = DosInput() 37 ppi = generate_dos_input() 38 39 ppi = BandsInput() 40 ppi = generate_bands_input() 41 42 ppi = ProjwfcInput() 43 ppi = generate_projwfc_input() 44 45 ppi = CpppInput() 46 ppi = generate_cppp_input() 47 48 ppi = PwexportInput() 49 ppi = generate_pwexport_input() 50 51#end def test_empty_init 52 53 54 55def test_read(): 56 import os 57 from generic import obj 58 from pwscf_postprocessors import ProjwfcInput 59 60 tpath = testing.setup_unit_test_output_directory('pwscf_postprocessor_input','test_read') 61 62 infile_path = os.path.join(tpath,'projwfc.in') 63 open(infile_path,'w').write(projwfc_in) 64 65 pi = ProjwfcInput(infile_path) 66 67 pi_ref = obj( 68 projwfc = obj( 69 prefix = 'pwscf', 70 outdir = 'pwscf_output', 71 ), 72 ) 73 74 assert(object_eq(pi.to_obj(),pi_ref)) 75#end def test_read 76 77 78 79def test_write(): 80 import os 81 from generic import obj 82 from pwscf_postprocessors import ProjwfcInput 83 84 tpath = testing.setup_unit_test_output_directory('pwscf_postprocessor_input','test_write') 85 86 infile_path = os.path.join(tpath,'projwfc.in') 87 open(infile_path,'w').write(projwfc_in) 88 89 write_path = os.path.join(tpath,'projwfc_write.in') 90 pi_write = ProjwfcInput(infile_path) 91 92 pi_write.write(write_path) 93 94 pi_read = ProjwfcInput(write_path) 95 96 pi_ref = obj( 97 projwfc = obj( 98 prefix = 'pwscf', 99 outdir = 'pwscf_output', 100 ), 101 ) 102 103 assert(object_eq(pi_read.to_obj(),pi_ref)) 104#end def test_write 105 106 107 108def test_generate(): 109 from generic import obj 110 from pwscf_postprocessors import generate_projwfc_input 111 112 pi = generate_projwfc_input( 113 prefix = 'pwscf', 114 outdir = 'pwscf_output', 115 ) 116 117 pi_ref = obj( 118 projwfc = obj( 119 prefix = 'pwscf', 120 outdir = 'pwscf_output', 121 ), 122 ) 123 124 assert(object_eq(pi.to_obj(),pi_ref)) 125#end def test_generate 126