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()

[((35, 4, 35, 19), 'unittest.main', 'unittest.main', ({}, {}), '()', False, 'import unittest\n'), ((10, 53, 10, 71), 'tempfile.mkstemp', 'tempfile.mkstemp', ({}, {}), '()', False, 'import tempfile\n'), ((12, 19, 12, 44), 'weather.app.test_client', 'weather.app.test_client', ({}, {}), '()', False, 'import weather\n'), ((13, 8, 13, 25), 'weather.init_db', 'weather.init_db', ({}, {}), '()', False, 'import weather\n'), ((16, 8, 16, 28), 'os.close', 'os.close', ({(16, 17, 16, 27): 'self.db_fd'}, {}), '(self.db_fd)', False, 'import os\n'), ((17, 8, 17, 49), 'os.unlink', 'os.unlink', ({(17, 18, 17, 48): "weather.app.config['DATABASE']"}, {}), "(weather.app.config['DATABASE'])", False, 'import os\n')]