Changeset 9266 for main/waeup.kofa/trunk/src/waeup/kofa/accesscodes/tests
- Timestamp:
- 2 Oct 2012, 06:43:52 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/accesscodes/tests
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/accesscodes/tests/sample_ac_data.csv
r9265 r9266 1 batch_num,batch_prefix,batch_serial,cost,history,owner,random_num,representation,state 2 1,CLR,33,100.0,2012-07-11 14:51:56 UTC - initialized by Manager||2012-07-11 14:55:42 UTC - invalidated by Manager,K1000009,1625368961#,CLR-1-1625368961,used 3 1,CLR,2,100.0,2012-05-12 16:32:29 UTC - initialized by Manager,,5468453598#,CLR-1-5468453598,initialized 4 1,HOS,731,0.0,2012-09-19 08:59:28 UTC - initialized by Manager,,0007044547#,HOS-1-0007044547,initialized 1 batch_num,batch_prefix,batch_serial,cost,history,owner,random_num,representation,state,transition 2 1,CLR,33,100.0,anything,K1000009,1625368961#,CLR-1-1625368961,used, 3 1,CLR,2,100.0,anything,,5468453598#,CLR-1-5468453598,initialized, 4 1,HOS,456,0.0,anything,,98769876#,HOS-1-98769876,,use 5 1,HOS,456,0.0,anything,,76254765#,HOS-1-76254765,, 6 1,HOS,23,0.0,anything,,0007044547#,HOS-1-0007044547,nonsense, 7 1,HOS,731,0.0,anything,,555#,HOS-1-555,used,disable_unused 8 1,HOS,456,0.0,anything,,666#,HOS-1-666,,nonsense 9 -
main/waeup.kofa/trunk/src/waeup/kofa/accesscodes/tests/test_batching.py
r9265 r9266 54 54 '\n')[0].split(',') 55 55 56 AC_SAMPLE_DATA_UPDATE = open( 57 os.path.join(os.path.dirname(__file__), 'sample_ac_data_update.csv'), 58 'rb').read() 59 60 AC_HEADER_FIELDS_UPDATE = AC_SAMPLE_DATA_UPDATE.split( 61 '\n')[0].split(',') 62 56 63 class ACFullSetup(FunctionalTestCase): 57 64 … … 104 111 self.assertTrue( 105 112 'system - AccessCodeBatch Processor - CLR-1 - ' 106 'Batch updated: num=1, creator=system, entry_num=3, '107 ' creation_date=2012-04-28 07:28:48.719026+00:00, '113 'Batch updated: num=1, creator=system, used_num=1, ' 114 'entry_num=3, creation_date=2012-04-28 07:28:48.719026+00:00, ' 108 115 'prefix=CLR, cost=0.0, disabled_num=0' 109 116 in logcontent) … … 115 122 layer = FunctionalLayer 116 123 117 def test_import (self):124 def test_import_create(self): 118 125 self.processor = AccessCodeBatchProcessor() 119 126 self.csv_file = os.path.join(self.workdir, 'sample_batch_data.csv') … … 126 133 num, num_warns, fin_file, fail_file = self.processor.doImport( 127 134 self.csv_file, AC_HEADER_FIELDS) 128 self.assertEqual(num_warns,0) 135 self.assertEqual(num_warns,3) 136 fail_file = open(fail_file).read() 137 self.assertTrue( 138 'HOS-1-0007044547,HOS,anything,state: not allowed' in fail_file) 139 self.assertTrue( 140 'HOS-1-555,HOS,anything,workflow: not allowed' in fail_file) 141 self.assertTrue( 142 'HOS-1-666,HOS,anything,transition: not allowed' in fail_file) 143 self.assertEqual( 144 self.app['accesscodes']['HOS-1']['HOS-1-98769876'].state, 'used') 145 self.assertEqual( 146 self.app['accesscodes']['HOS-1']['HOS-1-76254765'].state, 'initialized') 129 147 self.assertEqual( 130 148 self.app['accesscodes']['CLR-1']['CLR-1-1625368961'].batch_serial, 33) … … 133 151 self.assertEqual( 134 152 self.app['accesscodes']['CLR-1']['CLR-1-1625368961'].state, 'used') 153 self.assertMatches( 154 self.app['accesscodes']['CLR-1']['CLR-1-1625368961'].history, 155 "<YYYY-MM-DD hh:mm:ss> UTC - initialized by system|" 156 "|<YYYY-MM-DD hh:mm:ss> UTC - state 'used' set by system") 157 self.assertMatches( 158 self.app['accesscodes']['HOS-1']['HOS-1-98769876'].history, 159 "<YYYY-MM-DD hh:mm:ss> UTC - initialized by system|" 160 "|<YYYY-MM-DD hh:mm:ss> UTC - used by system") 135 161 logcontent = open(self.logfile).read() 136 162 self.assertTrue( 137 163 'INFO - system - AccessCode Processor - CLR-1-1625368961 - ' 138 'AC updated: state=used, history=2012-07-11 14:51:56 UTC - ' 139 'initialized by Manager||2012-07-11 14:55:42 UTC - ' 140 'invalidated by Manager, batch_serial=33, ' 141 'random_num=1625368961, cost=100.0, owner=K1000009' 164 'AC updated: state=used, batch_serial=33, random_num=1625368961, ' 165 'cost=100.0, owner=K1000009' 142 166 in logcontent) 143 167 shutil.rmtree(os.path.dirname(fin_file)) 144 168 return 169 170 def test_import_update(self): 171 self.processor = AccessCodeBatchProcessor() 172 self.csv_file = os.path.join(self.workdir, 'sample_batch_data.csv') 173 open(self.csv_file, 'wb').write(BATCH_SAMPLE_DATA) 174 self.processor.doImport(self.csv_file, BATCH_HEADER_FIELDS) 175 176 self.processor = AccessCodeProcessor() 177 self.csv_file = os.path.join(self.workdir, 'sample_ac_data.csv') 178 open(self.csv_file, 'wb').write(AC_SAMPLE_DATA) 179 num, num_warns, fin_file, fail_file = self.processor.doImport( 180 self.csv_file, AC_HEADER_FIELDS) 181 182 self.csv_file = os.path.join(self.workdir, 'sample_ac_data_update.csv') 183 open(self.csv_file, 'wb').write(AC_SAMPLE_DATA_UPDATE) 184 num, num_warns, fin_file, fail_file = self.processor.doImport( 185 self.csv_file, AC_HEADER_FIELDS_UPDATE, 'update') 186 fin_file = open(fin_file).read() 187 self.assertEqual(num_warns,0) 188 self.assertEqual( 189 self.app['accesscodes']['HOS-1']['HOS-1-98769876'].state, 'disabled') 190 self.assertEqual( 191 self.app['accesscodes']['CLR-1']['CLR-1-1625368961'].state, 'disabled') 192 self.assertMatches( 193 self.app['accesscodes']['CLR-1']['CLR-1-1625368961'].history, 194 "<YYYY-MM-DD hh:mm:ss> UTC - initialized by system|" 195 "|<YYYY-MM-DD hh:mm:ss> UTC - state 'used' set by system|" 196 "|<YYYY-MM-DD hh:mm:ss> UTC - state 'disabled' set by system") 197 self.assertMatches( 198 self.app['accesscodes']['HOS-1']['HOS-1-98769876'].history, 199 "<YYYY-MM-DD hh:mm:ss> UTC - initialized by system|" 200 "|<YYYY-MM-DD hh:mm:ss> UTC - used by system|" 201 "|<YYYY-MM-DD hh:mm:ss> UTC - disabled by system") 202 return
Note: See TracChangeset for help on using the changeset viewer.