def test_161010_timing(): """test how fast we can parse the file, over and over again""" sts = datetime.datetime.now() for _ in range(100): hmlparser(get_test_file("HML/HMLARX.txt")) ets = datetime.datetime.now() rate = (ets - sts).total_seconds() / 100. print("sec per parse %.4f" % (rate, )) assert rate < 1.
def test_161010_timing(): """test how fast we can parse the file, over and over again""" sts = datetime.datetime.now() for _ in range(100): hmlparser(get_test_file("HML/HMLARX.txt")) ets = datetime.datetime.now() rate = (ets - sts).total_seconds() / 100. print("sec per parse %.4f" % (rate,)) assert rate < 1.
def test_160826_hmlarx(dbcursor): """Lets dance""" utcnow = utc(2016, 8, 26, 8) prod = hmlparser(get_test_file("HML/HMLARX.txt"), utcnow=utcnow) prod.sql(dbcursor) assert not prod.warnings assert prod.data[0].stationname == "CEDAR RIVER 2 S St. Ansgar"
def real_parser(txn, buf): """ I'm gonna do the heavy lifting here """ prod = hmlparser(buf) prod.sql(txn) if len(prod.warnings) > 0: common.email_error("\n".join(prod.warnings), buf)
def test_160826_hmlarx(self): """Lets dance""" prod = hmlparser(get_file("HMLARX.txt")) prod.sql(self.txn) self.assertEquals(len(prod.warnings), 0, '\n'.join(prod.warnings)) self.assertEquals(prod.data[0].stationname, "CEDAR RIVER 2 S St. Ansgar")
def test_160826_hmlarx(self): """Lets dance""" prod = hmlparser(get_file("HMLARX.txt")) prod.sql(self.txn) self.assertEquals(len(prod.warnings), 0, '\n'.join(prod.warnings)) self.assertEquals(prod.data[0].stationname, "CEDAR RIVER 2 S St. Ansgar")
def test_190313_missingstage(dbcursor): """Figure out why this HML is missing stage info.""" prod = hmlparser(get_test_file("HML/HMLDMX.txt")) assert not prod.warnings prod.sql(dbcursor) dbcursor.execute(""" SELECT * from hml_observed_data_2019 WHERE station = 'JANI4' and valid > '2019-03-13' and valid < '2019-03-14' """) assert dbcursor.rowcount == 8
def test_190313_missingstage(dbcursor): """Figure out why this HML is missing stage info.""" prod = hmlparser(get_test_file("HML/HMLDMX.txt")) assert not prod.warnings prod.sql(dbcursor) dbcursor.execute(""" SELECT * from hml_observed_data_2019 WHERE station = 'JANI4' and valid > '2019-03-13' and valid < '2019-03-14' """) assert dbcursor.rowcount == 8
def test_200926_nokey(dbcursor): """Test that we add a new observation key, when necessary.""" prod = hmlparser(get_test_file("HML/HMLMOB.txt")) prod.sql(dbcursor) dbcursor.execute( "SELECT key from hml_observed_data WHERE station = 'EFRA1' " "and valid >= '2020-09-26 13:36+00' and valid < '2020-09-26 13:43+00' " "and key is null" ) assert dbcursor.rowcount == 0
def real_parser(txn, buf): """I'm gonna do the heavy lifting here""" prod = hmlparser(buf) prod.sql(txn) if prod.warnings: common.email_error("\n".join(prod.warnings), buf)
def test_160826_hmlarx(dbcursor): """Lets dance""" prod = hmlparser(get_test_file("HML/HMLARX.txt")) prod.sql(dbcursor) assert not prod.warnings assert prod.data[0].stationname == "CEDAR RIVER 2 S St. Ansgar"