Exemplo n.º 1
0
 def test_station_dict_returns_instance(self):
     first = station.Station('first')
     second = station.Station('second')
     expected = first
     # Look at the station_dict; does it contain a ref to 'first'?
     actual = second.station_dict['first']
     self.assertEqual(actual, expected)
Exemplo n.º 2
0
 def test_station_dict_keeps_keys(self):
     first = station.Station('first')
     second = station.Station('second')
     actual = first.station_dict
     self.assertIn('first', actual)
     self.assertIn('second', actual)
     self.assertEqual(
         len(actual), 2, "The dict length is not equal to the \
                                         number of instances")
Exemplo n.º 3
0
 def test_station_setters_work(self):
     actual = station.Station("A", "B", "C", "D")
     self.assertIsInstance(actual, station.Station)
     self.assertEqual(actual.site, "A")
     self.assertEqual(actual.service, "B")
     self.assertEqual(actual.start_date, "C")
     self.assertEqual(actual.end_date, "D")
Exemplo n.º 4
0
    def test_station_subclasses_maintain_same_station_dict(self):
        class Foo(station.Station):
            pass

        foo_inst = Foo('foo')
        station_inst = station.Station('station')
        self.assertIn('station', foo_inst.station_dict)
        self.assertIn('foo', station_inst.station_dict)
        actual = station_inst.station_dict['foo']
        self.assertIsInstance(actual, Foo)
Exemplo n.º 5
0
    def test_station_subclasses_maintain_same_station_dict(self):
        class Foo(station.Station):
            pass

        foo_inst = Foo("foo")
        station_inst = station.Station("station")
        self.assertIn("station", foo_inst.station_dict)
        self.assertIn("foo", station_inst.station_dict)
        actual = station_inst.station_dict["foo"]
        self.assertIsInstance(actual, Foo)
Exemplo n.º 6
0
 def test_multiple_instances_only_one_list(self):
     first = station.Station('first')
     second = station.Station('second')
     self.assertEqual(first.station_dict, second.station_dict)
Exemplo n.º 7
0
 def test_station_dict_returns_dict(self):
     actual = station.Station('first')
     self.assertIsInstance(actual.station_dict, dict)
Exemplo n.º 8
0
 def test_station_id_sets(self):
     expected = "01234567"
     actual = station.Station(expected)
     another = station.Station("23456789")
     self.assertEqual(actual.site, expected)
     self.assertEqual(another.site, "23456789")
Exemplo n.º 9
0
 def test_station_site_defaults_to_None(self):
     actual = station.Station()
     self.assertIsNone(actual.site)
Exemplo n.º 10
0
 def test_station_is_obj(self):
     actual = station.Station()
     self.assertIsInstance(actual, station.Station)
Exemplo n.º 11
0
 def test_station_fetch2_calls_get_nwis_correctly(self, mock_get_nwis):
     actual = station.Station("A", "B", "2002-03-03", "2002-03-03")
     try_it_out = actual.fetch()
     # This won't raise TypeError for "C" not matching "yyyy-mm-dd"
     mock_get_nwis.assert_called_once_with("A", "B", "2002-03-03",
                                           "2002-03-03")
Exemplo n.º 12
0
 def test_station_fetch_calls_get_nwis_correctly(self, mock_get_nwis):
     actual = station.Station("A", "B", "1111-11-11", "1111-11-11")
     try_it_out = actual.fetch()
     mock_get_nwis.assert_called_once_with("A", "B", "1111-11-11",
                                           "1111-11-11")
Exemplo n.º 13
0
 def test_station_end_defaults_to_None(self):
     actual = station.Station()
     self.assertIsNone(actual.end_date)
Exemplo n.º 14
0
 def test_station_service_defaults_to_dv(self):
     actual = station.Station()
     service = "problem!"
     self.assertEqual(actual.service, "dv")
Exemplo n.º 15
0
 def test_station_site_sets(self):
     expected = "0123"
     actual = station.Station(expected)
     another = station.Station("ABC")
     self.assertEqual(actual.site, expected)
     self.assertEqual(another.site, "ABC")