Changeset 17787 for main/waeup.kofa/trunk/src/waeup/kofa/tests
- Timestamp:
- 15 May 2024, 06:42:58 (6 months ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/tests
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/tests/test_configuration.py
r17782 r17787 30 30 from waeup.kofa.configuration import ( 31 31 ConfigurationContainer, SessionConfiguration, SessionConfigurationFactory, 32 ConfigurationContainerExporter, ConfigurationExporter) 33 from waeup.kofa.interfaces import(ICSVExporter, 32 ConfigurationContainerExporter, SessionConfigurationExporter, 33 ConfigurationContainerProcessor, SessionConfigurationProcessor) 34 from waeup.kofa.interfaces import(ICSVExporter, IBatchProcessor, 34 35 IConfigurationContainer, ISessionConfiguration, ISessionConfigurationAdd) 35 36 … … 124 125 result = open(self.outfile, 'rb').read() 125 126 self.assertTrue( 126 'acronym,ca ptcha,carry_over,current_academic_session,email_admin,'127 'email_subject,export_disabled_message,frontpage, frontpage_dict,'127 'acronym,carry_over,current_academic_session,email_admin,' 128 'email_subject,export_disabled_message,frontpage,' 128 129 'maintmode_enabled_by,name,name_admin,next_matric_integer,' 129 130 'next_matric_integer_2,next_matric_integer_3,' 130 131 'next_matric_integer_4,smtp_mailer,curr_stud_id\r\n' 131 'WAeUP.Kofa, No captcha,0,,contact@waeup.org,Kofa Contact,,'132 'WAeUP.Kofa,0,,contact@waeup.org,Kofa Contact,,' 132 133 '"<h1>Welcome to WAeUP.Kofa\n<br>' in result 133 134 ) … … 138 139 def test_ifaces(self): 139 140 # make sure we fullfill interface contracts 140 obj = ConfigurationExporter()141 obj = SessionConfigurationExporter() 141 142 verify.verifyObject(ICSVExporter, obj) 142 verify.verifyClass(ICSVExporter, ConfigurationExporter)143 verify.verifyClass(ICSVExporter, SessionConfigurationExporter) 143 144 return 144 145 145 146 def test_get_as_utility(self): 146 147 # we can get a faculty exporter as utility 147 result = queryUtility(ICSVExporter, name=" configurations")148 result = queryUtility(ICSVExporter, name="sessionconfigurations") 148 149 self.assertTrue(result is not None) 149 150 return … … 154 155 self.sessionconfig.clearance_fee = 3000.6 155 156 self.app['configuration'].addSessionConfiguration(self.sessionconfig) 156 exporter = ConfigurationExporter()157 exporter = SessionConfigurationExporter() 157 158 exporter.export_all(self.app, self.outfile) 158 159 result = open(self.outfile, 'rb').read() … … 164 165 ) 165 166 return 167 168 BASECONFIG_SAMPLE_DATA = open( 169 os.path.join(os.path.dirname(__file__), 'sample_baseconfig_data.csv'), 170 'rb').read() 171 172 BASECONFIG_HEADER_FIELDS = BASECONFIG_SAMPLE_DATA.split( 173 '\n')[0].split(',') 174 175 class BaseConfigurationProcessorTests(ConfigurationImportExportSetup): 176 177 layer = FunctionalLayer 178 179 def setUp(self): 180 super(BaseConfigurationProcessorTests, self).setUp() 181 self.processor = ConfigurationContainerProcessor() 182 183 def test_interface(self): 184 # Make sure we fulfill the interface contracts. 185 assert verify.verifyObject(IBatchProcessor, self.processor) is True 186 assert verify.verifyClass( 187 IBatchProcessor, ConfigurationContainerProcessor) is True 188 189 def test_import(self): 190 self.csv_file = os.path.join( 191 self.workdir, 'sample_baseconfig_data.csv') 192 open(self.csv_file, 'wb').write(BASECONFIG_SAMPLE_DATA) 193 num, num_warns, fin_file, fail_file = self.processor.doImport( 194 self.csv_file, BASECONFIG_HEADER_FIELDS,'update') 195 self.assertEqual(num_warns,0) 196 configcontainer = self.processor.getEntry(dict(), self.app) 197 self.assertEqual(configcontainer.frontpage, 'Hello World') 198 199 SESSIONCONFIG_SAMPLE_DATA = open( 200 os.path.join(os.path.dirname(__file__), 'sample_sessionconfig_data.csv'), 201 'rb').read() 202 203 SESSIONCONFIG_HEADER_FIELDS = SESSIONCONFIG_SAMPLE_DATA.split( 204 '\n')[0].split(',') 205 206 class SessionConfigurationProcessorTests(ConfigurationImportExportSetup): 207 208 layer = FunctionalLayer 209 210 def setUp(self): 211 super(SessionConfigurationProcessorTests, self).setUp() 212 self.processor = SessionConfigurationProcessor() 213 214 def test_interface(self): 215 # Make sure we fulfill the interface contracts. 216 assert verify.verifyObject(IBatchProcessor, self.processor) is True 217 assert verify.verifyClass( 218 IBatchProcessor, SessionConfigurationProcessor) is True 219 220 def test_import(self): 221 self.csv_file = os.path.join( 222 self.workdir, 'sample_sessionconfig_data.csv') 223 open(self.csv_file, 'wb').write(SESSIONCONFIG_SAMPLE_DATA) 224 num, num_warns, fin_file, fail_file = self.processor.doImport( 225 self.csv_file, SESSIONCONFIG_HEADER_FIELDS,'create') 226 self.assertEqual(num_warns,0) 227 sessionconfig = self.processor.getEntry({'academic_session':'2017'}, self.app) 228 self.assertEqual(sessionconfig.payment_disabled[0], 'sf_all') 229 230
Note: See TracChangeset for help on using the changeset viewer.