def test_type_check(self): try: seq = coastal_data.coastal_seq("EDEN_3", 'nonesuch') self.assertTrue(False, "expected") self.assertIsNone(seq) except TypeError: self.assertTrue(True, "expected")
def _coastal_sequence(self): try: return coastal_seq(self.gage_name, self.param, beginDate=self.beginDate, endDate=self.endDate) except KeyError: raise NoData(self.gage_name, self.param)
def test_funky_gage_name(self): gage_name = "G-3777" # yes it exists q = coastal_data.coastal_query(gage_name, DataParams.stage) self.assertIn(gage_name, str(q)) seq = coastal_data.coastal_seq(gage_name, "stage") for t in seq: self.assertIsNotNone(t[0])
def test_get(self): d1 = datetime.datetime(2011, 3, 12, 4, 31) d2 = datetime.datetime(2011, 3, 12, 22, 59) seq = coastal_data.coastal_seq("Lostmans_River_below_Second_Bay", DataParams.salinity, beginDate=d1, endDate=d2) for t in seq: print t d_obs = t[0] self.assertLessEqual(d1, d_obs, "not less than beginDate") self.assertLessEqual(d_obs, d2, "not greater than endDate")