@@ -105,17 +105,16 @@ def test_am_binary_bulletin():
105
105
bulletin , firstchars , lines , missing_ahl , station , charset = _get_bulletin_info (message_test1 )
106
106
107
107
bulletinHeader = lines [0 ].decode ('iso-8859-1' ).replace (' ' , '_' )
108
- message_test1 ['new_file' ] = bulletinHeader + '__12345'
109
- message_test1 ['new_dir' ] = BaseOptions .directory
108
+ message_test1 ['relPath' ] = BaseOptions .directory + bulletinHeader + '__12345'
110
109
message_test1 ['content' ]['value' ] = b64encode (message_test1 ['content' ]['value' ]).decode ('ascii' )
111
110
message_test1 ["isProblem" ] = False
112
111
113
112
worklist = make_worklist ()
114
113
worklist .incoming = [message_test1 ]
115
114
116
115
# Check renamer.
117
- renamer .after_accept (worklist )
118
- assert worklist .incoming [0 ]['new_file' ] == 'ISAA41_CYWA_030000___00001'
116
+ renamer .after_gather (worklist )
117
+ assert worklist .incoming [0 ]['relPath' ]. split ( '/' )[ - 1 ] == 'ISAA41_CYWA_030000___00001'
119
118
120
119
121
120
# Test 2: Check a regular CACN bulletin
@@ -132,8 +131,7 @@ def test_cacn_regular():
132
131
bulletin , firstchars , lines , missing_ahl , station , charset = _get_bulletin_info (message_test2 )
133
132
134
133
bulletinHeader = lines [0 ].decode ('iso-8859-1' ).replace (' ' , '_' )
135
- message_test2 ['new_file' ] = bulletinHeader + '__12345'
136
- message_test2 ['new_dir' ] = BaseOptions .directory
134
+ message_test2 ['relPath' ] = BaseOptions .directory + bulletinHeader + '__12345'
137
135
138
136
# Check correcting the bulletin contents of a CACN
139
137
new_bulletin , isProblem = am_instance .correctContents (bulletin , firstchars , lines , missing_ahl , station , charset )
@@ -147,8 +145,8 @@ def test_cacn_regular():
147
145
worklist = make_worklist ()
148
146
worklist .incoming = [message_test2 ]
149
147
150
- renamer .after_accept (worklist )
151
- assert worklist .incoming [0 ]['new_file' ] == 'CACN00_CWAO_021600__WVO_00001'
148
+ renamer .after_gather (worklist )
149
+ assert worklist .incoming [0 ]['relPath' ]. split ( '/' )[ - 1 ] == 'CACN00_CWAO_021600__WVO_00001'
152
150
153
151
# Test 3: Check an erronous CACN bulletin (missing timestamp in bulletin contents)
154
152
def test_cacn_erronous ():
@@ -180,8 +178,8 @@ def test_cacn_erronous():
180
178
worklist .incoming = [message_test3 ]
181
179
182
180
183
- renamer .after_accept (worklist )
184
- assert re .match ('CACN00_CWAO_......__WPK_00001_PROBLEM' , worklist .incoming [0 ]['new_file' ])
181
+ renamer .after_gather (worklist )
182
+ assert re .match ('CACN00_CWAO_......__WPK_00001_PROBLEM' , worklist .incoming [0 ]['relPath' ]. split ( '/' )[ - 1 ])
185
183
186
184
# Test 4: Bulletin with double line separator after header (my-header\n\n)
187
185
def test_bulletin_double_linesep ():
@@ -212,8 +210,8 @@ def test_bulletin_double_linesep():
212
210
worklist = make_worklist ()
213
211
worklist .incoming = [message_test4 ]
214
212
215
- renamer .after_accept (worklist )
216
- assert message_test4 ['new_file' ] == 'SXCN35_CWVR_021100___00001'
213
+ renamer .after_gather (worklist )
214
+ assert message_test4 ['relPath' ]. split ( '/' )[ - 1 ] == 'SXCN35_CWVR_021100___00001'
217
215
218
216
# Test 5: Bulletin with invalid year in timestamp (Fix: https://github.com/MetPX/sarracenia/pull/973)
219
217
def test_bulletin_invalid_timestamp (caplog ):
@@ -230,8 +228,8 @@ def test_bulletin_invalid_timestamp(caplog):
230
228
bulletin , firstchars , lines , missing_ahl , station , charset = _get_bulletin_info (message_test5 )
231
229
232
230
bulletinHeader = lines [0 ].decode ('iso-8859-1' ).replace (' ' , '_' )
233
- message_test5 ['new_file' ] = bulletinHeader + '__12345'
234
- message_test5 ['new_dir' ] = BaseOptions .directory
231
+ message_test5 ['relPath' ]. split ( '/' )[ - 1 ] = bulletinHeader + '__12345'
232
+ message_test5 ['relPath' ]. split ( '/' )[ - 2 : ] = BaseOptions .directory
235
233
236
234
new_bulletin , isProblem = am_instance .correctContents (bulletin , firstchars , lines , missing_ahl , station , charset )
237
235
assert new_bulletin == b'CACN00 CWAO\n WVO\n 100,1024,123,1600,0,100,13.5,5.6,79.4,0.722,11.81,11.74,1.855,6.54,16.76,1544,2.344,14.26,0,375.6,375.6,375.5,375.5,0,11.58,11.24,3.709,13.89,13.16,11.22,11,9.45,11.39,5.033,79.4,0.694,-6999,41.19,5.967,5.887,5.93,6.184,5.64,5.066,5.253,-6999,7.3,0.058,0,5.715,4.569,0,0,1.942,-6999,57.4,0,0.531,-6999,1419,1604,1787,-6999,-6999,-6999,-6999,-6999,1601,-6999,-6999,6,5.921,5.956,6.177,5.643,5.07,5.256,-6999,9.53,11.22,10.09,10.61,125.4,9.1\n '
@@ -242,7 +240,7 @@ def test_bulletin_invalid_timestamp(caplog):
242
240
worklist = make_worklist ()
243
241
worklist .incoming = [message_test5 ]
244
242
245
- renamer .after_accept (worklist )
243
+ renamer .after_gather (worklist )
246
244
# We want to make sure the proper errors are raised from the logs
247
245
assert 'Unable to fetch header contents. Skipping message' in caplog .text and 'Unable to verify year from julian time.' in caplog .text
248
246
@@ -299,8 +297,8 @@ def test_bulletin_wrong_station():
299
297
worklist = make_worklist ()
300
298
worklist .incoming = [message_test7 ]
301
299
302
- renamer .after_accept (worklist )
303
- assert message_test7 [ 'new_file' ] == 'UECN99_CYCX_071200___00001_PROBLEM'
300
+ renamer .after_gather (worklist )
301
+ assert worklist . incoming [ 0 ][ 'relPath' ]. split ( '/' )[ - 1 ] == 'UECN99_CYCX_071200___00001_PROBLEM'
304
302
305
303
# Test 8: SM Bulletin - Add station mapping + SM/SI bulletin accomodities
306
304
def test_SM_bulletin ():
@@ -330,8 +328,8 @@ def test_SM_bulletin():
330
328
worklist = make_worklist ()
331
329
worklist .incoming = [message_test8 ]
332
330
333
- renamer .after_accept (worklist )
334
- assert message_test8 [ 'new_file' ] == 'SMCN06_CWAO_030000__71816_00001'
331
+ renamer .after_gather (worklist )
332
+ assert worklist . incoming [ 0 ][ 'relPath' ]. split ( '/' )[ - 1 ] == 'SMCN06_CWAO_030000__71816_00001'
335
333
336
334
# Test 9: Bulletin with 5 fields in header (invalid)
337
335
def test_bulletin_header_five_fileds ():
@@ -347,8 +345,7 @@ def test_bulletin_header_five_fileds():
347
345
bulletin , firstchars , lines , missing_ahl , station , charset = _get_bulletin_info (message_test9 )
348
346
349
347
bulletinHeader = lines [0 ].decode ('iso-8859-1' ).replace (' ' , '_' )
350
- message_test9 ['new_file' ] = bulletinHeader + '__12345'
351
- message_test9 ['new_dir' ] = BaseOptions .directory
348
+ message_test9 ['relPath' ] = BaseOptions .directory + bulletinHeader + '__12345'
352
349
353
350
# Check correcting the bulletin contents of the bulletin
354
351
new_bulletin , isProblem = am_instance .correctContents (bulletin , firstchars , lines , missing_ahl , station , charset )
@@ -422,8 +419,8 @@ def test_random_bulletin_with_BBB():
422
419
worklist = make_worklist ()
423
420
worklist .incoming = [message_test12 ]
424
421
425
- renamer .after_accept (worklist )
426
- assert message_test12 [ 'new_file' ] == 'FXCN06_CYTR_230939_AAA__00001'
422
+ renamer .after_gather (worklist )
423
+ assert worklist . incoming [ 0 ][ 'relPath' ]. split ( '/' )[ - 1 ] == 'FXCN06_CYTR_230939_AAA__00001'
427
424
428
425
# Test 13: SM Bulletin with BBB - Add station mapping + SM/SI bulletin accomodities + conserve BBB header
429
426
def test_SM_bulletin_with_BBB ():
@@ -453,5 +450,5 @@ def test_SM_bulletin_with_BBB():
453
450
worklist = make_worklist ()
454
451
worklist .incoming = [message_test13 ]
455
452
456
- renamer .after_accept (worklist )
457
- assert message_test13 [ 'new_file' ] == 'SMCN06_CWAO_030000_AAA_71816_00001'
453
+ renamer .after_gather (worklist )
454
+ assert worklist . incoming [ 0 ][ 'relPath' ]. split ( '/' )[ - 1 ] == 'SMCN06_CWAO_030000_AAA_71816_00001'
0 commit comments