def test_140604_sbwupdate(dbcursor): """Make sure we are updating the right info in the sbw table """ utcnow = utc(2014, 6, 4) dbcursor.execute("""DELETE from sbw_2014 where wfo = 'LMK' and eventid = 95 and phenomena = 'SV' and significance = 'W' """) dbcursor.execute("""DELETE from warnings_2014 where wfo = 'LMK' and eventid = 95 and phenomena = 'SV' and significance = 'W' """) prod = vtecparser(get_test_file('SVRLMK_1.txt'), utcnow=utcnow) prod.sql(dbcursor) dbcursor.execute("""SELECT expire from sbw_2014 WHERE wfo = 'LMK' and eventid = 95 and phenomena = 'SV' and significance = 'W' """) assert dbcursor.rowcount == 1 prod = vtecparser(get_test_file('SVRLMK_2.txt'), utcnow=utcnow) prod.sql(dbcursor) dbcursor.execute("""SELECT expire from sbw_2014 WHERE wfo = 'LMK' and eventid = 95 and phenomena = 'SV' and significance = 'W' """) assert dbcursor.rowcount == 3 warnings = filter_warnings(prod.warnings) assert not warnings
def test_181228_issue76_sbwtable(dbcursor): """Can we locate the current SBW table with polys in the future.""" prod = vtecparser(get_test_file('FLWMOB/FLW.txt')) prod.sql(dbcursor) prod = vtecparser(get_test_file('FLWMOB/FLS.txt')) prod.sql(dbcursor) assert not filter_warnings(prod.warnings)
def test_140604_sbwupdate(self): ''' Make sure we are updating the right info in the sbw table ''' utcnow = datetime.datetime(2014, 6, 4) utcnow = utcnow.replace(tzinfo=pytz.timezone("UTC")) self.txn.execute("""DELETE from sbw_2014 where wfo = 'LMK' and eventid = 95 and phenomena = 'SV' and significance = 'W' """) self.txn.execute("""DELETE from warnings_2014 where wfo = 'LMK' and eventid = 95 and phenomena = 'SV' and significance = 'W' """) prod = vtecparser(get_file('SVRLMK_1.txt'), utcnow=utcnow) prod.sql(self.txn) self.txn.execute("""SELECT expire from sbw_2014 WHERE wfo = 'LMK' and eventid = 95 and phenomena = 'SV' and significance = 'W' """) self.assertEqual(self.txn.rowcount, 1) prod = vtecparser(get_file('SVRLMK_2.txt'), utcnow=utcnow) prod.sql(self.txn) self.txn.execute("""SELECT expire from sbw_2014 WHERE wfo = 'LMK' and eventid = 95 and phenomena = 'SV' and significance = 'W' """) self.assertEqual(self.txn.rowcount, 3) warnings = filter_warnings(prod.warnings) self.assertEqual(len(warnings), 0, "\n".join(warnings))
def test_201120_resent(dbcursor): """Test that we can handle a resent product.""" data = get_test_file("TOR.txt") prod = vtecparser(data) prod.sql(dbcursor) eas = "EAS ACTIVATION REQUESTED" prod = vtecparser(data.replace(eas, f"{eas}...RESENT")) prod.sql(dbcursor)
def test_201006_invalid_warning(dbcursor): """Test that we don't complain about a dangling CON statement.""" prod = vtecparser(get_test_file("MWWPQR/MWWPQR_0.txt")) prod.sql(dbcursor) assert not filter_warnings(prod.warnings) prod = vtecparser(get_test_file("MWWPQR/MWWPQR_1.txt")) prod.sql(dbcursor) assert not filter_warnings(prod.warnings)
def test_150115_correction_sbw(self): """ FLWMHX make sure a correction does not result in two polygons """ prod = vtecparser(get_file('FLWMHX/0.txt')) prod.sql(self.txn) warnings = filter_warnings(prod.warnings) self.assertEquals(len(warnings), 0, "\n".join(warnings)) prod = vtecparser(get_file('FLWMHX/1.txt')) prod.sql(self.txn) warnings = filter_warnings(prod.warnings) self.assertEquals(len(warnings), 0, "\n".join(warnings))
def test_171121_issue45(dbcursor): """Do we alert on duplicated ETNs?""" utcnow = utc(2017, 4, 20, 21, 33) prod = vtecparser(get_test_file('vtec/NPWDMX_0.txt'), utcnow=utcnow) prod.sql(dbcursor) utcnow = utc(2017, 11, 20, 21, 33) prod = vtecparser(get_test_file('vtec/NPWDMX_1.txt'), utcnow=utcnow) prod.sql(dbcursor) warnings = filter_warnings(prod.warnings) assert len(warnings) == 1
def test_issue284_incomplete_update(dbcursor): """Test that we emit warnings when a product fails to update everything.""" prod = vtecparser(get_test_file("FFW/FFWLCH_0.txt")) prod.sql(dbcursor) assert not filter_warnings(prod.warnings) prod = vtecparser(get_test_file("FFW/FFSLCH_1.txt")) prod.sql(dbcursor) warnings = filter_warnings(prod.warnings) assert len(warnings) == 1 assert warnings[0].startswith(CUGC)
def test_200306_issue210(dbcursor): """Test our logic for figuring out which table has our event.""" for i in range(7): prod = vtecparser(get_test_file("FLWCHS/2019_%s.txt" % (i, ))) prod.sql(dbcursor) assert not filter_warnings(prod.warnings) for i in range(2): prod = vtecparser(get_test_file("FLWCHS/2020_%s.txt" % (i, ))) prod.sql(dbcursor) assert not filter_warnings(prod.warnings)
def test_201120_sbw_duplicate(dbcursor): """Test that we get an error for a SBW duplicated.""" data = get_test_file("TOR.txt") prod = vtecparser(data) prod.sql(dbcursor) prod.sql(dbcursor) assert any([x.find("is a SBW duplicate") > -1 for x in prod.warnings]) prod = vtecparser(data.replace(".NEW.", ".CON.")) prod.sql(dbcursor) assert any([x.find("SBW prev polygon") > -1 for x in prod.warnings])
def test_150115_correction_sbw(dbcursor): """ FLWMHX make sure a correction does not result in two polygons """ prod = vtecparser(get_test_file('FLWMHX/0.txt')) prod.sql(dbcursor) warnings = filter_warnings(prod.warnings) assert not warnings prod = vtecparser(get_test_file('FLWMHX/1.txt')) prod.sql(dbcursor) warnings = filter_warnings(prod.warnings) assert not warnings
def test_vtec_series(dbcursor): """Test a lifecycle of WSW products """ prod = vtecparser(get_test_file('WSWDMX/WSW_00.txt')) assert prod.afos == 'WSWDMX' prod.sql(dbcursor) # Did Marshall County IAZ049 get a ZR.Y dbcursor.execute(""" SELECT issue from warnings_2013 WHERE wfo = 'DMX' and eventid = 1 and phenomena = 'ZR' and significance = 'Y' and status = 'EXB' and ugc = 'IAZ049' """) assert dbcursor.rowcount == 1 prod = vtecparser(get_test_file('WSWDMX/WSW_01.txt')) assert prod.afos == 'WSWDMX' prod.sql(dbcursor) # Is IAZ006 in CON status with proper end time answer = utc(2013, 1, 28, 6) dbcursor.execute("""SELECT expire from warnings_2013 WHERE wfo = 'DMX' and eventid = 1 and phenomena = 'WS' and significance = 'W' and status = 'CON' and ugc = 'IAZ006' """) assert dbcursor.rowcount == 1 row = dbcursor.fetchone() assert row[0] == answer # No change for i in range(2, 9): prod = vtecparser(get_test_file('WSWDMX/WSW_%02i.txt' % (i,))) assert prod.afos == 'WSWDMX' prod.sql(dbcursor) prod = vtecparser(get_test_file('WSWDMX/WSW_09.txt')) assert prod.afos == 'WSWDMX' prod.sql(dbcursor) # IAZ006 should be cancelled answer = utc(2013, 1, 28, 5, 38) dbcursor.execute("""SELECT expire from warnings_2013 WHERE wfo = 'DMX' and eventid = 1 and phenomena = 'WS' and significance = 'W' and status = 'CAN' and ugc = 'IAZ006' """) assert dbcursor.rowcount == 1 row = dbcursor.fetchone() assert row[0] == answer
def test_vtec_series(self): ''' Test a lifecycle of WSW products ''' prod = vtecparser(get_file('WSWDMX/WSW_00.txt')) self.assertEqual(prod.afos, 'WSWDMX') prod.sql(self.txn) ''' Did Marshall County IAZ049 get a ZR.Y ''' self.txn.execute(""" SELECT issue from warnings_2013 WHERE wfo = 'DMX' and eventid = 1 and phenomena = 'ZR' and significance = 'Y' and status = 'EXB' and ugc = 'IAZ049' """) self.assertEqual(self.txn.rowcount, 1) prod = vtecparser(get_file('WSWDMX/WSW_01.txt')) self.assertEqual(prod.afos, 'WSWDMX') prod.sql(self.txn) ''' Is IAZ006 in CON status with proper end time ''' answer = utc(2013, 1, 28, 6) self.txn.execute("""SELECT expire from warnings_2013 WHERE wfo = 'DMX' and eventid = 1 and phenomena = 'WS' and significance = 'W' and status = 'CON' and ugc = 'IAZ006' """) self.assertEqual(self.txn.rowcount, 1) row = self.txn.fetchone() self.assertEqual(row[0], answer) # No change for i in range(2, 9): prod = vtecparser(get_file('WSWDMX/WSW_%02i.txt' % (i,))) self.assertEqual(prod.afos, 'WSWDMX') prod.sql(self.txn) prod = vtecparser(get_file('WSWDMX/WSW_09.txt')) self.assertEqual(prod.afos, 'WSWDMX') prod.sql(self.txn) # IAZ006 should be cancelled answer = utc(2013, 1, 28, 5, 38) self.txn.execute("""SELECT expire from warnings_2013 WHERE wfo = 'DMX' and eventid = 1 and phenomena = 'WS' and significance = 'W' and status = 'CAN' and ugc = 'IAZ006' """) self.assertEqual(self.txn.rowcount, 1) row = self.txn.fetchone() self.assertEqual(row[0], answer)
def test_vtec_series(dbcursor): """Test a lifecycle of WSW products """ prod = vtecparser(get_test_file('WSWDMX/WSW_00.txt')) assert prod.afos == 'WSWDMX' prod.sql(dbcursor) # Did Marshall County IAZ049 get a ZR.Y dbcursor.execute(""" SELECT issue from warnings_2013 WHERE wfo = 'DMX' and eventid = 1 and phenomena = 'ZR' and significance = 'Y' and status = 'EXB' and ugc = 'IAZ049' """) assert dbcursor.rowcount == 1 prod = vtecparser(get_test_file('WSWDMX/WSW_01.txt')) assert prod.afos == 'WSWDMX' prod.sql(dbcursor) # Is IAZ006 in CON status with proper end time answer = utc(2013, 1, 28, 6) dbcursor.execute("""SELECT expire from warnings_2013 WHERE wfo = 'DMX' and eventid = 1 and phenomena = 'WS' and significance = 'W' and status = 'CON' and ugc = 'IAZ006' """) assert dbcursor.rowcount == 1 row = dbcursor.fetchone() assert row[0] == answer # No change for i in range(2, 9): prod = vtecparser(get_test_file('WSWDMX/WSW_%02i.txt' % (i, ))) assert prod.afos == 'WSWDMX' prod.sql(dbcursor) prod = vtecparser(get_test_file('WSWDMX/WSW_09.txt')) assert prod.afos == 'WSWDMX' prod.sql(dbcursor) # IAZ006 should be cancelled answer = utc(2013, 1, 28, 5, 38) dbcursor.execute("""SELECT expire from warnings_2013 WHERE wfo = 'DMX' and eventid = 1 and phenomena = 'WS' and significance = 'W' and status = 'CAN' and ugc = 'IAZ006' """) assert dbcursor.rowcount == 1 row = dbcursor.fetchone() assert row[0] == answer
def test_181228_issue76_sbwtable(dbcursor): """Can we locate the current SBW table with polys in the future.""" prod = vtecparser(get_test_file("FLWMOB/FLW.txt")) prod.sql(dbcursor) prod = vtecparser(get_test_file("FLWMOB/FLS.txt")) prod.sql(dbcursor) dbcursor.execute( "SELECT * from sbw_2018 where wfo = 'MOB' and eventid = 57 " "and phenomena = 'FL' and significance = 'W' and status = 'NEW'") row = dbcursor.fetchone() assert row["hvtec_nwsli"] == "MRRM6" assert row["hvtec_severity"] == "1" assert row["hvtec_cause"] == "ER" assert row["hvtec_record"] == "NO" assert not filter_warnings(prod.warnings)
def test_TORE_series(dbcursor): """Can we process a Tornado Emergency that came with SVS update.""" def getval(): dbcursor.execute(""" SELECT is_emergency from warnings_2018 WHERE wfo = 'DMX' and eventid = 43 and phenomena = 'TO' and significance = 'W' and ugc = 'IAC127' """) return dbcursor.fetchone()[0] def getval2(): dbcursor.execute(""" SELECT is_emergency from sbw_2018 WHERE wfo = 'DMX' and eventid = 43 and phenomena = 'TO' and significance = 'W' and status != 'CAN' ORDER by updated DESC """) return dbcursor.fetchone()[0] def getval3(): dbcursor.execute(""" select is_emergency from sbw_2018 where wfo = 'DMX' and eventid = 43 and phenomena = 'TO' and significance = 'W' """) return dbcursor.rowcount prod = vtecparser(get_test_file("TORE/TOR.txt")) prod.sql(dbcursor) assert getval3() == 1 jmsg = prod.get_jabbers("http://localhost") assert "TO.EMERGENCY" not in jmsg[0][2]["channels"].split(",") assert getval() is False assert getval2() is False prod = vtecparser(get_test_file("TORE/SVS_E.txt")) prod.sql(dbcursor) assert getval3() == 3 assert not prod.warnings jmsg = prod.get_jabbers("http://localhost") assert "TO.EMERGENCY" in jmsg[0][2]["channels"].split(",") assert getval() assert getval2() # no longer an emergency, but we don't want database to update prod = vtecparser(get_test_file("TORE/SVS_F.txt")) prod.sql(dbcursor) assert getval() assert getval2() is False
def test_141210_continues(self): """ See that we handle CON with infinite time A-OK """ for i in range(0, 2): prod = vtecparser(get_file('FFAEKA/%i.txt' % (i,))) prod.sql(self.txn) warnings = filter_warnings(prod.warnings) self.assertEquals(len(warnings), 0, "\n".join(warnings))
def test_141023_upgrade(dbcursor): """ See that we can handle the upgrade and downgrade dance """ for i in range(1, 8): prod = vtecparser(get_test_file('NPWBOX/NPW_%02i.txt' % (i,))) prod.sql(dbcursor) warnings = filter_warnings(prod.warnings) assert not warnings
def test_140610_no_vtec_time(dbcursor): """ A VTEC Product with both 0000 for start and end time, sigh """ utcnow = utc(2014, 6, 10, 0, 56) prod = vtecparser(get_test_file('FLSLZK_notime.txt'), utcnow=utcnow) prod.sql(dbcursor) assert prod.segments[0].vtec[0].begints is None assert prod.segments[0].vtec[0].endts is None
def test_151225_extfuture(self): """Warning failure jumps states!""" # /O.NEW.KPAH.FL.W.0093.151227T0517Z-151228T1727Z/ prod = vtecparser(get_file('FLWPAH/FLWPAH_1.txt')) prod.sql(self.txn) self.txn.execute(""" SELECT ugc, issue, expire from warnings_2015 where wfo = 'PAH' and phenomena = 'FL' and eventid = 93 and significance = 'W' and status = 'NEW' """) self.assertEquals(self.txn.rowcount, 2) # /O.EXT.KPAH.FL.W.0093.151227T0358Z-151229T0442Z/ prod = vtecparser(get_file('FLWPAH/FLWPAH_2.txt')) prod.sql(self.txn) warnings = filter_warnings(prod.warnings) self.assertEquals(len(warnings), 1, '\n'.join(warnings))
def test_wcn_updates(): """ Make sure our Tags and svs_special works for combined message """ utcnow = utc(2014, 6, 6, 20, 37) ugc_provider = {} for u in range(1, 201, 2): n = 'a' * int(min((u+1/2), 40)) for st in ['AR', 'MS', 'TN', 'MO']: ugc_provider["%sC%03i" % (st, u)] = UGC(st, 'C', "%03i" % (u,), name=n, wfos=['DMX']) prod = vtecparser(get_test_file('WCNMEG.txt'), utcnow=utcnow, ugc_provider=ugc_provider) j = prod.get_jabbers('http://localhost', 'http://localhost') ans = ( 'MEG updates Severe Thunderstorm Watch (expands area to include ' 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa [MO] and 11 counties in ' '[TN], continues 12 counties in [AR] and ' 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa [MO] and 22 counties in ' '[MS] and aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, ' 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, ' 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, ' 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, ' 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, ' 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa [TN]) till Jun 6, 7:00 PM ' 'CDT. http://localhost2014-O-EXA-KMEG-SV-A-0240' ) assert j[0][0] == ans
def test_routine(dbcursor): """what can we do with a ROU VTEC product """ utcnow = utc(2014, 6, 19, 2, 56) prod = vtecparser(get_test_file('FLWMKX_ROU.txt'), utcnow=utcnow) prod.sql(dbcursor) warnings = filter_warnings(prod.warnings) assert not warnings
def test_160720_unknown_ugc(self): """Unknown UGC logic failed for some reason""" # Note that this example has faked UGCs to test things out prod = vtecparser(get_file('RFWBOI_fakeugc.txt')) prod.sql(self.txn) self.assertEquals(len(prod.warnings), 2, '\n'.join(prod.warnings))
def test_141210_continues(dbcursor): """ See that we handle CON with infinite time A-OK """ for i in range(0, 2): prod = vtecparser(get_test_file('FFAEKA/%i.txt' % (i,))) prod.sql(dbcursor) warnings = filter_warnings(prod.warnings) assert not warnings
def test_issue9(dbcursor): """A product crossing year bondary""" utcnow = utc(2017, 12, 31, 9, 24) prod = vtecparser(get_test_file('vtec/crosses_0.txt'), utcnow=utcnow) prod.sql(dbcursor) utcnow = utc(2018, 1, 1, 16, 0) prod = vtecparser(get_test_file('vtec/crosses_1.txt'), utcnow=utcnow) prod.sql(dbcursor) warnings = filter_warnings(prod.warnings) # We used to emit a warning for this, but not any more assert not warnings utcnow = utc(2018, 1, 1, 21, 33) prod = vtecparser(get_test_file('vtec/crosses_2.txt'), utcnow=utcnow) prod.sql(dbcursor) warnings = filter_warnings(prod.warnings) assert not warnings
def test_170115_table_failure(dbcursor): """Test WSW series for issues""" for i in range(12): print('Parsing Product: %s.txt' % (i,)) prod = vtecparser(get_test_file('WSWAMA/WSWAMA_%02i.txt' % (i,))) prod.sql(dbcursor) assert not filter_warnings(prod.warnings)
def test_150102_multiyear(dbcursor): """ WSWOUN See how well we span multiple years """ for i in range(13): print(datetime.datetime.utcnow()) print('Parsing Product: %s.txt' % (i,)) prod = vtecparser(get_test_file('WSWOUN/%i.txt' % (i,))) prod.sql(dbcursor) # Make sure there are no null issue times dbcursor.execute(""" SELECT count(*) from warnings_2014 where wfo = 'OUN' and eventid = 16 and phenomena = 'WW' and significance = 'Y' and issue is null """) assert dbcursor.fetchone()[0] == 0 if i == 5: dbcursor.execute(""" SELECT issue from warnings_2014 WHERE ugc = 'OKZ036' and wfo = 'OUN' and eventid = 16 and phenomena = 'WW' and significance = 'Y' """) row = dbcursor.fetchone() assert row[0] == utc(2015, 1, 1, 6, 0) warnings = filter_warnings(prod.warnings) warnings = filter_warnings(warnings, "Segment has duplicated") warnings = filter_warnings(warnings, "VTEC Product appears to c") assert not warnings
def test_160912_missing(dbcursor): """see why this series failed in production""" for i in range(4): prod = vtecparser(get_test_file("RFWVEF/RFW_%02i.txt" % (i,))) prod.sql(dbcursor) warnings = filter_warnings(prod.warnings) assert not warnings
def test_151225_extfuture(dbcursor): """Warning failure jumps states!""" # /O.NEW.KPAH.FL.W.0093.151227T0517Z-151228T1727Z/ prod = vtecparser(get_test_file('FLWPAH/FLWPAH_1.txt')) prod.sql(dbcursor) dbcursor.execute(""" SELECT ugc, issue, expire from warnings_2015 where wfo = 'PAH' and phenomena = 'FL' and eventid = 93 and significance = 'W' and status = 'NEW' """) assert dbcursor.rowcount == 2 # /O.EXT.KPAH.FL.W.0093.151227T0358Z-151229T0442Z/ prod = vtecparser(get_test_file('FLWPAH/FLWPAH_2.txt')) prod.sql(dbcursor) warnings = filter_warnings(prod.warnings) assert len(warnings) == 2
def really_process_data(buf): """ Actually do some processing """ gmtnow = datetime.datetime.utcnow() gmtnow = gmtnow.replace(tzinfo=pytz.utc) # Make sure we have a trailing $$, if not report error and slap one on if buf.find("$$") == -1: common.email_error("No $$ Found!", buf) buf += "\n\n$$\n\n" # Create our TextProduct instance text_product = vtecparser(buf, utcnow=gmtnow, ugc_provider=ugc_dict, nwsli_provider=nwsli_dict) # Don't parse these as they contain duplicated information if text_product.source == "KNHC" and text_product.afos[:3] == "TCV": return # Skip spanish products if text_product.source == "TJSJ" and text_product.afos[3:] == "SPN": return df = PGCONN.runInteraction(text_product.sql) df.addCallback(step2, text_product) df.addErrback(common.email_error, text_product.unixtext) df.addErrback(log.err)
def test_160912_missing(dbcursor): """see why this series failed in production""" for i in range(4): prod = vtecparser(get_test_file("RFWVEF/RFW_%02i.txt" % (i, ))) prod.sql(dbcursor) warnings = filter_warnings(prod.warnings) assert not warnings
def test_141023_upgrade(self): """ See that we can handle the upgrade and downgrade dance """ for i in range(1, 8): prod = vtecparser(get_file('NPWBOX/NPW_%02i.txt' % (i,))) prod.sql(self.txn) warnings = filter_warnings(prod.warnings) self.assertEquals(len(warnings), 0, "\n".join(warnings))
def test_141212_mqt(dbcursor): """ Updated four rows instead of three, better check on it """ for i in range(4): print("Parsing Product: %s.txt" % (i, )) prod = vtecparser(get_test_file("MWWMQT/%i.txt" % (i, ))) prod.sql(dbcursor) assert not filter_warnings(filter_warnings(prod.warnings), CUGC)
def test_141023_upgrade(dbcursor): """ See that we can handle the upgrade and downgrade dance """ for i in range(1, 8): prod = vtecparser(get_test_file('NPWBOX/NPW_%02i.txt' % (i, ))) prod.sql(dbcursor) warnings = filter_warnings(prod.warnings) assert not warnings
def test_141210_continues(dbcursor): """ See that we handle CON with infinite time A-OK """ for i in range(0, 2): prod = vtecparser(get_test_file('FFAEKA/%i.txt' % (i, ))) prod.sql(dbcursor) warnings = filter_warnings(prod.warnings) assert not warnings
def test_routine(self): ''' what can we do with a ROU VTEC product ''' utcnow = utc(2014, 6, 19, 2, 56) prod = vtecparser(get_file('FLWMKX_ROU.txt'), utcnow=utcnow) prod.sql(self.txn) warnings = filter_warnings(prod.warnings) self.assertEquals(len(warnings), 0)
def test_wcn_updates(): """ Make sure our Tags and svs_special works for combined message """ utcnow = utc(2014, 6, 6, 20, 37) ugc_provider = {} for u in range(1, 201, 2): n = 'a' * int(min((u + 1 / 2), 40)) for st in ['AR', 'MS', 'TN', 'MO']: ugc_provider["%sC%03i" % (st, u)] = UGC(st, 'C', "%03i" % (u, ), name=n, wfos=['DMX']) prod = vtecparser(get_test_file('WCNMEG.txt'), utcnow=utcnow, ugc_provider=ugc_provider) j = prod.get_jabbers('http://localhost', 'http://localhost') ans = ( 'MEG updates Severe Thunderstorm Watch (expands area to include ' 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa [MO] and 11 counties in ' '[TN], continues 12 counties in [AR] and ' 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa [MO] and 22 counties in ' '[MS] and aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, ' 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, ' 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, ' 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, ' 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, ' 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa [TN]) till Jun 6, 7:00 PM ' 'CDT. http://localhost2014-O-EXA-KMEG-SV-A-0240') assert j[0][0] == ans
def test_150102_multiyear(dbcursor): """ WSWOUN See how well we span multiple years """ for i in range(13): print(datetime.datetime.utcnow()) print('Parsing Product: %s.txt' % (i, )) prod = vtecparser(get_test_file('WSWOUN/%i.txt' % (i, ))) prod.sql(dbcursor) # Make sure there are no null issue times dbcursor.execute(""" SELECT count(*) from warnings_2014 where wfo = 'OUN' and eventid = 16 and phenomena = 'WW' and significance = 'Y' and issue is null """) assert dbcursor.fetchone()[0] == 0 if i == 5: dbcursor.execute(""" SELECT issue from warnings_2014 WHERE ugc = 'OKZ036' and wfo = 'OUN' and eventid = 16 and phenomena = 'WW' and significance = 'Y' """) row = dbcursor.fetchone() assert row[0] == utc(2015, 1, 1, 6, 0) warnings = filter_warnings(prod.warnings) warnings = filter_warnings(warnings, "Segment has duplicated") warnings = filter_warnings(warnings, "VTEC Product appears to c") assert not warnings
def test_wcn_updates(): """ Make sure our Tags and svs_special works for combined message """ utcnow = utc(2014, 6, 6, 20, 37) ugc_provider = {} for u in range(1, 201, 2): n = "a" * int(min((u + 1 / 2), 40)) for st in ["AR", "MS", "TN", "MO"]: ugc_provider["%sC%03i" % (st, u)] = UGC(st, "C", "%03i" % (u, ), name=n, wfos=["DMX"]) prod = vtecparser(get_test_file("WCNMEG.txt"), utcnow=utcnow, ugc_provider=ugc_provider) j = prod.get_jabbers("http://localhost", "http://localhost") ans = ( "MEG updates Severe Thunderstorm Watch (expands area to include " "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa [MO] and 11 counties in " "[TN], continues 12 counties in [AR] and " "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa [MO] and 22 counties in " "[MS] and aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, " "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, " "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, " "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, " "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, " "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa [TN]) till Jun 6, 7:00 PM " "CDT. http://localhost2014-O-EXA-KMEG-SV-A-0240_2014-06-06T20:37Z") assert j[0][0] == ans
def test_170115_table_failure(dbcursor): """Test WSW series for issues""" for i in range(12): print('Parsing Product: %s.txt' % (i, )) prod = vtecparser(get_test_file('WSWAMA/WSWAMA_%02i.txt' % (i, ))) prod.sql(dbcursor) assert not filter_warnings(prod.warnings)
def test_141211_null_expire(dbcursor): """ Figure out why the database has a null expiration for this FL.W""" for i in range(0, 13): print('Parsing Product: %s.txt' % (i, )) prod = vtecparser(get_test_file('FLSIND/%i.txt' % (i, ))) prod.sql(dbcursor) warnings = filter_warnings(prod.warnings) assert not filter_warnings(warnings, 'LAT...LON')
def test_141215_correction(dbcursor): """ I have a feeling we are not doing the right thing for COR """ for i in range(6): print('Parsing Product: %s.txt' % (i, )) prod = vtecparser(get_test_file('NPWMAF/%i.txt' % (i, ))) prod.sql(dbcursor) warnings = filter_warnings(prod.warnings) assert not warnings
def test_150105_manycors(dbcursor): """ WSWGRR We had some issues with this series, lets test it """ for i in range(15): print('Parsing Product: %s.txt' % (i, )) prod = vtecparser(get_test_file('WSWGRR/%i.txt' % (i, ))) prod.sql(dbcursor) warnings = filter_warnings(prod.warnings) assert not warnings
def test_150105_sbw(dbcursor): """ FLSLBF SBW that spans two years! """ for i in range(7): print('Parsing Product: %s.txt' % (i, )) prod = vtecparser(get_test_file('FLSLBF/%i.txt' % (i, ))) prod.sql(dbcursor) warnings = filter_warnings(prod.warnings) assert not warnings
def test_180411_can_expiration(dbcursor): """Do we properly update the expiration time of a CAN event""" utcnow = utc(2018, 1, 22, 2, 6) prod = vtecparser(get_test_file('vtec/TORFWD_0.txt'), utcnow=utcnow) prod.sql(dbcursor) # This should be the expiration time as well utcnow = utc(2018, 1, 22, 2, 30) prod = vtecparser(get_test_file('vtec/TORFWD_1.txt'), utcnow=utcnow) prod.sql(dbcursor) for status in ['NEW', 'CAN']: dbcursor.execute(""" SELECT expire from sbw_2018 where wfo = 'FWD' and phenomena = 'TO' and significance = 'W' and eventid = 6 and status = %s """, (status, )) row = dbcursor.fetchone() assert row[0] == utcnow
def test_150105_sbw(dbcursor): """ FLSLBF SBW that spans two years! """ for i in range(7): print('Parsing Product: %s.txt' % (i,)) prod = vtecparser(get_test_file('FLSLBF/%i.txt' % (i,))) prod.sql(dbcursor) warnings = filter_warnings(prod.warnings) assert not warnings
def test_160912_missing(self): """see why this series failed in production""" for i in range(4): prod = vtecparser(get_file("RFWVEF/RFW_%02i.txt" % (i,))) prod.sql(self.txn) warnings = filter_warnings(prod.warnings) self.assertEquals(len(warnings), 0, '\n'.join(warnings))
def test_150105_manycors(dbcursor): """ WSWGRR We had some issues with this series, lets test it """ for i in range(15): print('Parsing Product: %s.txt' % (i,)) prod = vtecparser(get_test_file('WSWGRR/%i.txt' % (i,))) prod.sql(dbcursor) warnings = filter_warnings(prod.warnings) assert not warnings
def test_141212_mqt(dbcursor): """ Updated four rows instead of three, better check on it """ for i in range(4): print('Parsing Product: %s.txt' % (i,)) prod = vtecparser(get_test_file('MWWMQT/%i.txt' % (i,))) prod.sql(dbcursor) warnings = filter_warnings(prod.warnings) assert not warnings
def test_201120_missing_ugc(dbcursor): """Test that a warning for missing ugc is emitted.""" data = get_test_file("CFW/CFWSJU.txt") data = data.replace("PRZ001-002-005-008-211645-", "") prod = vtecparser(data) prod.sql(dbcursor) ans = "UGC is missing for segment that has VTEC!" assert ans in prod.warnings
def test_141211_null_expire(dbcursor): """ Figure out why the database has a null expiration for this FL.W""" for i in range(0, 13): print('Parsing Product: %s.txt' % (i,)) prod = vtecparser(get_test_file('FLSIND/%i.txt' % (i,))) prod.sql(dbcursor) warnings = filter_warnings(prod.warnings) assert not filter_warnings(warnings, 'LAT...LON')
def test_141215_correction(dbcursor): """ I have a feeling we are not doing the right thing for COR """ for i in range(6): print('Parsing Product: %s.txt' % (i,)) prod = vtecparser(get_test_file('NPWMAF/%i.txt' % (i,))) prod.sql(dbcursor) warnings = filter_warnings(prod.warnings) assert not warnings