import os
import weather
import datetime
import unittest
import tempfile

class WeatherTestCase(unittest.TestCase):

    def setUp(self):
        self.db_fd, weather.app.config['DATABASE'] = tempfile.mkstemp()
        weather.app.config['TESTING'] = True
        self.app = weather.app.test_client()
        weather.init_db()

    def tearDown(self):
        os.close(self.db_fd)
        os.unlink(weather.app.config['DATABASE'])

    def test_empty_db(self):
        """Test empty database with no entries."""
        rv = self.app.get('/')
        assert 'Nothing logged yet.' in rv.data

    def test_report(self):
        """Test reporting weather"""
        rv = self.app.get('/report/11210/63/23', follow_redirects=True)
        assert b'11210' in rv.data

    def test_full_db(self):
        """Test reporting weather"""
        rv = self.app.get('/', follow_redirects=True)
        assert b'11210' in rv.data

if __name__ == '__main__':
    unittest.main()

[((949, 964), 'unittest.main', 'unittest.main', ([], {}), '()\n', (962, 964), False, 'import unittest\n'), ((191, 209), 'tempfile.mkstemp', 'tempfile.mkstemp', ([], {}), '()\n', (207, 209), False, 'import tempfile\n'), ((274, 299), 'weather.app.test_client', 'weather.app.test_client', ([], {}), '()\n', (297, 299), False, 'import weather\n'), ((308, 325), 'weather.init_db', 'weather.init_db', ([], {}), '()\n', (323, 325), False, 'import weather\n'), ((359, 379), 'os.close', 'os.close', (['self.db_fd'], {}), '(self.db_fd)\n', (367, 379), False, 'import os\n'), ((388, 429), 'os.unlink', 'os.unlink', (["weather.app.config['DATABASE']"], {}), "(weather.app.config['DATABASE'])\n", (397, 429), False, 'import os\n')]