Beispiel #1
0
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)
Beispiel #2
0
def test_mcdparser(dbcursor):
    ''' Test Parsing of MCD Product '''
    prod = parser(get_test_file('MCD_MPD/SWOMCD.txt'))
    assert abs(prod.geometry.area - 4.302) < 0.001
    assert prod.discussion_num == 1525
    assert prod.attn_wfo[2] == 'DLH'
    ans = "PORTIONS OF NRN WI AND THE UPPER PENINSULA OF MI"
    assert prod.areas_affected == ans

    # With probability this time
    prod = parser(get_test_file('MCD_MPD/SWOMCDprob.txt'))
    assert abs(prod.geometry.area - 2.444) < 0.001
    assert prod.watch_prob == 20

    jmsg = prod.get_jabbers('http://localhost')
    ans = (
        '<p>Storm Prediction Center issues '
        '<a href="http://www.spc.noaa.gov/'
        'products/md/2013/md1678.html">Mesoscale Discussion #1678</a> '
        '[watch probability: 20%] (<a href="http://localhost'
        '?pid=201308091725-KWNS-ACUS11-SWOMCD">View text</a>)</p>')
    assert jmsg[0][1] == ans
    ans = (
        'Storm Prediction Center issues Mesoscale Discussion #1678 '
        '[watch probability: 20%] '
        'http://www.spc.noaa.gov/products/md/2013/md1678.html')
    assert jmsg[0][0] == ans
    ans = utc(2013, 8, 9, 17, 25)
    assert prod.sts == ans
    ans = utc(2013, 8, 9, 19, 30)
    assert prod.ets == ans

    prod.database_save(dbcursor)
Beispiel #3
0
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
Beispiel #4
0
def test_read():
    """Can we process an entire file?"""
    for line in get_test_file("NCEI/DS3505.txt", fponly=True):
        data = parser(line.decode('ascii').strip(), 'ENJA')
        assert data is not None

    for line in get_test_file("NCEI/DS3505_KAMW_2016.txt", fponly=True):
        data = parser(line.decode('ascii').strip(), 'KAMW')
        assert data is not None
Beispiel #5
0
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
Beispiel #6
0
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
Beispiel #7
0
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
Beispiel #8
0
def test_winter_mex(cursor):
    """Test that we store the GFSX fields in the winter."""
    utcnow = utc(2020, 9, 1, 0)
    prod = mosparser(get_test_file("MOS/MEXNC1_winter.txt"), utcnow=utcnow)
    assert len(prod.data) == 2
    inserts = prod.sql(cursor)
    assert inserts == 30
Beispiel #9
0
def test_nbm_v32_station(cursor):
    """Can we parse the NBM v3.2 data."""
    utcnow = utc(2020, 2, 19, 17)
    prod = mosparser(get_test_file("MOS/NBSUSA_32_station.txt"), utcnow=utcnow)
    assert len(prod.data) == 4
    inserts = prod.sql(cursor)
    assert inserts == 92
Beispiel #10
0
def test_sql(dbcursor):
    """Test that we can insert into the database."""
    prod = parser(get_test_file("LSR/LSRDVN_old.txt"))
    assert prod.lsrs
    for lsr in prod.lsrs:
        lsr.sql(dbcursor)
        assert dbcursor.rowcount == 1
Beispiel #11
0
def test_080731_invalid():
    """Make sure that the SIG wind threshold does not eat the US"""
    spc = parser(get_test_file('SPCPTS/PTSDY1_biggeom.txt'))
    # spc.draw_outlooks()
    outlook = spc.get_outlook('WIND', 'SIGN', 1)
    assert abs(outlook.geometry.area - 15.82) < 0.01
    assert len(spc.warnings) == 1
Beispiel #12
0
def test_future():
    """Can we handle products that are around the first"""
    utcnow = utc(2017, 12, 1)
    prod = PARSER(get_test_file("METAR/first.txt"), utcnow=utcnow)
    assert len(prod.metars) == 2
    assert prod.metars[0].time.month == 11
    assert prod.metars[1].time.month == 12
Beispiel #13
0
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
Beispiel #14
0
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
Beispiel #15
0
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
Beispiel #16
0
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
Beispiel #17
0
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)
Beispiel #18
0
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
Beispiel #19
0
def test_future():
    """Can we handle products that are around the first"""
    utcnow = utc(2017, 12, 1)
    prod = PARSER(get_test_file("METAR/first.txt"), utcnow=utcnow)
    assert len(prod.metars) == 2
    assert prod.metars[0].time.month == 11
    assert prod.metars[1].time.month == 12
Beispiel #20
0
def test_lav(cursor):
    """Test that we can parse the GFS LAMP."""
    utcnow = utc(2020, 7, 10, 12, 30)
    prod = mosparser(get_test_file("MOS/LAVUSA.txt"), utcnow=utcnow)
    assert len(prod.data) == 3
    inserts = prod.sql(cursor)
    assert inserts == 75
Beispiel #21
0
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
Beispiel #22
0
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
Beispiel #23
0
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
Beispiel #24
0
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
Beispiel #25
0
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
Beispiel #26
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
Beispiel #27
0
def test_170809_nocrcrlf():
    """Product fails WMO parsing due to usage of RTD as bbb field"""
    utcnow = utc(2017, 8, 9, 9)
    prod = PARSER(
        get_test_file("METAR/rtd_bbb.txt"), utcnow=utcnow,
        nwsli_provider=NWSLI_PROVIDER)
    assert len(prod.metars) == 1
Beispiel #28
0
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
Beispiel #29
0
def test_170612_nullgeom(dbcursor):
    """See why this has an error with null geom reported"""
    spc = parser(get_test_file('SPCPTS/PTSD48_nullgeom.txt'))
    # spc.draw_outlooks()
    spc.sql(dbcursor)
    outlook = spc.get_outlook('ANY SEVERE', '0.15', 4)
    assert abs(outlook.geometry.area - 56.84) < 0.01
Beispiel #30
0
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
Beispiel #31
0
def test_170815_pywwa_issue3():
    """This example was in pyWWA issues list, so lets test here"""
    utcnow = utc(2015, 9, 30, 16, 56)

    tp = parser(get_test_file('SIGMETS/SIGE.txt'), utcnow,
                nwsli_provider=NWSLI_PROVIDER)
    assert len(tp.sigmets) == 4
Beispiel #32
0
def test_ugc_error130214():
    """ Check parsing of SPSJAX  """
    tp = product.TextProduct(get_test_file('SPSJAX.txt'))
    assert tp.segments[0].ugcs, [
        ugc.UGC("FL", "Z", 23), ugc.UGC("FL", "Z", 25),
        ugc.UGC("FL", "Z", 30), ugc.UGC("FL", "Z", 31),
        ugc.UGC("FL", "Z", 32)]
Beispiel #33
0
def test_200930_nbx_int(cursor):
    """Test a problem found with the product."""
    utcnow = utc(2020, 9, 30, 12)
    prod = mosparser(get_test_file("MOS/NBXUSA_int.txt"), utcnow=utcnow)
    assert len(prod.data) == 6
    inserts = prod.sql(cursor)
    assert inserts == 84
Beispiel #34
0
def test_bullets():
    """ Test bullets parsing """
    tp = product.TextProduct(get_test_file('TORtag.txt'))
    assert len(tp.segments[0].bullets) == 4
    ans = (
        "LOCATIONS IMPACTED INCLUDE... MARYSVILLE...LOVILIA"
        "...HAMILTON AND BUSSEY.")
    assert tp.segments[0].bullets[3] == ans

    tp = product.TextProduct(get_test_file('FLSDMX.txt'))
    assert len(tp.segments[2].bullets) == 7
    ans = (
        "IMPACT...AT 35.5 FEET...WATER AFFECTS 285TH "
        "AVENUE NEAR SEDAN BOTTOMS...OR JUST EAST OF THE "
        "INTERSECTION OF 285TH AVENUE AND 570TH STREET.")
    assert tp.segments[2].bullets[6] == ans
Beispiel #35
0
def test_mex(cursor):
    """Test that we can parse the Extended GFS MEX."""
    utcnow = utc(2020, 7, 10, 12)
    prod = mosparser(get_test_file("MOS/MEXNC1.txt"), utcnow=utcnow)
    assert len(prod.data) == 4
    inserts = prod.sql(cursor)
    assert inserts == 60
Beispiel #36
0
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
Beispiel #37
0
def test_ecmwf(cursor):
    """Test that we can parse the ECMWF MOS."""
    utcnow = utc(2020, 2, 24, 0)
    prod = mosparser(get_test_file("MOS/ECS.txt"), utcnow=utcnow)
    assert len(prod.data) == 3
    inserts = prod.sql(cursor)
    assert inserts == 63
Beispiel #38
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
Beispiel #39
0
def test_valid_nomnd():
    """ check valid (no Mass News) Parsing """
    utcnow = utc(2012, 11, 27)
    tp = product.TextProduct(
        get_test_file('AFD_noMND.txt'), utcnow=utcnow)
    ts = utc(2012, 11, 27, 0, 1)
    assert tp.valid == ts
Beispiel #40
0
def test_1():
    """ PIREP.txt, can we parse it! """
    utcnow = utc(2015, 1, 9, 0, 0)
    nwsli_provider = {
        'BIL': {
            'lat': 44,
            'lon': 99
        },
        'LBY': {
            'lat': 45,
            'lon': 100
        },
        'PUB': {
            'lat': 46,
            'lon': 101
        },
        'HPW': {
            'lat': 47,
            'lon': 102
        }
    }
    prod = pirepparser(get_test_file('PIREPS/PIREP.txt'),
                       utcnow=utcnow,
                       nwsli_provider=nwsli_provider)
    assert not prod.warnings

    j = prod.get_jabbers()
    assert j[0][2]['channels'] == 'UA.None,UA.PIREP'
Beispiel #41
0
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
Beispiel #42
0
def test_150126_space():
    """ space.txt has a space where it should not """
    nwsli_provider = {'CZBA': {'lat': 44.26, 'lon': -88.52}}
    prod = pirepparser(get_test_file('PIREPS/space.txt'),
                       nwsli_provider=nwsli_provider)
    assert not prod.warnings
    assert abs(prod.reports[0].latitude - 44.15) < 0.01
Beispiel #43
0
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)
Beispiel #44
0
def test_080731_invalid():
    """Make sure that the SIG wind threshold does not eat the US"""
    spc = parser(get_test_file('SPCPTS/PTSDY1_biggeom.txt'))
    # spc.draw_outlooks()
    outlook = spc.get_outlook('WIND', 'SIGN', 1)
    assert abs(outlook.geometry.area - 15.82) < 0.01
    assert len(spc.warnings) == 1
Beispiel #45
0
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(filter_warnings(prod.warnings), CUGC)
    assert len(warnings) == 1
Beispiel #46
0
def test_170926_largeenh(dbcursor):
    """This Day1 generated a massive ENH"""
    spc = parser(get_test_file('SPCPTS/PTSDY1_bigenh.txt'))
    # spc.draw_outlooks()
    spc.sql(dbcursor)
    outlook = spc.get_outlook('CATEGORICAL', 'ENH', 1)
    assert abs(outlook.geometry.area - 17.50) < 0.01
Beispiel #47
0
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)
Beispiel #48
0
def test_170612_nullgeom(dbcursor):
    """See why this has an error with null geom reported"""
    spc = parser(get_test_file('SPCPTS/PTSD48_nullgeom.txt'))
    # spc.draw_outlooks()
    spc.sql(dbcursor)
    outlook = spc.get_outlook('ANY SEVERE', '0.15', 4)
    assert abs(outlook.geometry.area - 56.84) < 0.01
Beispiel #49
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_2014-06-06T20:37Z")
    assert j[0][0] == ans
Beispiel #50
0
def test_170428_large(dbcursor):
    """PTSDY1 has a large 10 tor"""
    spc = parser(get_test_file('SPCPTS/PTSDY1_largetor10.txt'))
    # spc.draw_outlooks()
    spc.sql(dbcursor)
    outlook = spc.get_outlook('TORNADO', '0.10', 1)
    assert abs(outlook.geometry.area - 31.11) < 0.01
Beispiel #51
0
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
Beispiel #52
0
def test_180321_mst():
    """Do we do the right thing with MST products whilst in DST"""
    tp = productparser(get_test_file("AFDMST.txt"))
    res = tp.get_jabbers("http://localhost")
    ans = ("PSR issues Area Forecast Discussion (AFD) at Mar 21, 5:15 AM "
           "MST http://localhost?pid=201803211215-KPSR-FXUS65-AFDPSR")
    assert res[0][0] == ans
Beispiel #53
0
def test_170824_sa_format():
    """Don't be so noisey when we encounter SA formatted products"""
    utcnow = utc(2017, 8, 24, 14)
    prod = PARSER(
        get_test_file("METAR/sa.txt"), utcnow=utcnow,
        nwsli_provider=NWSLI_PROVIDER)
    assert not prod.metars
Beispiel #54
0
def test_now_jabber():
    """ See if we can process a NOW and get the jabber result """
    tp = product.TextProduct(get_test_file("NOWDMX.txt"))
    j = tp.get_jabbers("http://localhost")
    ans = ("DMX issues Short-term Forecast (NOW) at Mar 4, 8:42 AM CST "
           "http://localhost?pid=201003041442-KDMX-FPUS73-NOWDMX")
    assert j[0][0] == ans
Beispiel #55
0
def test_150126_space():
    """ space.txt has a space where it should not """
    nwsli_provider = {'CZBA': {'lat': 44.26, 'lon': -88.52}}
    prod = pirepparser(
        get_test_file('PIREPS/space.txt'), nwsli_provider=nwsli_provider)
    assert not prod.warnings
    assert abs(prod.reports[0].latitude - 44.15) < 0.01
Beispiel #56
0
def test_wpc():
    """Can we deal with the AWIPS ID in WPC products."""
    tp = productparser(get_test_file("PMDSA.txt"))
    res = tp.get_jabbers("http://localhost")
    ans = ("WBC issues South America Forecast Discussion (PMD) at Jul 13, "
           "11:17 AM EDT http://localhost?pid=202007131517-KWBC-FXSA20-PMDSA")
    assert res[0][0] == ans
Beispiel #57
0
def test_170926_largeenh(dbcursor):
    """This Day1 generated a massive ENH"""
    spc = parser(get_test_file('SPCPTS/PTSDY1_bigenh.txt'))
    # spc.draw_outlooks()
    spc.sql(dbcursor)
    outlook = spc.get_outlook('CATEGORICAL', 'ENH', 1)
    assert abs(outlook.geometry.area - 17.50) < 0.01
Beispiel #58
0
def test_200731_cvt():
    """See that we handle CVT timezone products."""
    tp = productparser(get_test_file("TCDAT5_CVT.txt"))
    res = tp.get_jabbers("http://localhost")
    ans = ("NHC issues TCDAT5 (TCD) at Jul 31, 8:00 PM CVT "
           "http://localhost?pid=202007312100-KNHC-WTNT45-TCDAT5")
    assert res[0][0] == ans
Beispiel #59
0
def test_170428_large(dbcursor):
    """PTSDY1 has a large 10 tor"""
    spc = parser(get_test_file('SPCPTS/PTSDY1_largetor10.txt'))
    # spc.draw_outlooks()
    spc.sql(dbcursor)
    outlook = spc.get_outlook('TORNADO', '0.10', 1)
    assert abs(outlook.geometry.area - 31.11) < 0.01
Beispiel #60
0
def test_190503_badgeom():
    """This SIGMET produced a traceback in prod."""
    utcnow = utc(2019, 5, 3, 18, 25)
    tp = parser(
        get_test_file('SIGMETS/SIGC_badgeom.txt'), utcnow,
        nwsli_provider=NWSLI_PROVIDER)
    assert len(tp.sigmets) == 4