Exemplo n.º 1
0
 def test_set_location(self):
     c = Client()
     response = c.post("/nabweatherd/settings", {"location": "75005"})
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.templates[0].name,
                      "nabweatherd/settings.html")
     self.assertTrue("config" in response.context)
     config = Config.load()
     self.assertEqual(response.context["config"], config)
     self.assertEqual(config.location, "75005")
     self.assertEqual(config.next_performance_date, None)
     self.assertEqual(config.next_performance_type, None)
Exemplo n.º 2
0
 def test_get_settings(self):
     c = Client()
     response = c.get("/nabweatherd/settings")
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.templates[0].name,
                      "nabweatherd/settings.html")
     self.assertTrue("config" in response.context)
     config = Config.load()
     self.assertEqual(response.context["config"], config)
     self.assertEqual(config.location, None)
     self.assertEqual(config.unit, 1)
     self.assertEqual(config.next_performance_date, None)
Exemplo n.º 3
0
 def test_forecast_tomorrow(self):
     c = Client()
     response = c.put("/nabweatherd/settings", "type=tomorrow")
     self.assertEqual(response.status_code, 200)
     response_json = response.json()
     self.assertTrue("status" in response_json)
     self.assertEqual(response_json["status"], "ok")
     config = Config.load()
     now = datetime.datetime.now(datetime.timezone.utc)
     self.assertTrue(config.next_performance_date < now)
     self.assertTrue(config.next_performance_date > now -
                     datetime.timedelta(seconds=15))
     self.assertEqual(config.next_performance_type, "tomorrow")
Exemplo n.º 4
0
 def test_get_settings(self):
     c = Client()
     response = c.get("/nabweatherd/settings")
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.templates[0].name,
                      "nabweatherd/settings.html")
     self.assertTrue("config" in response.context)
     config = Config.load()
     self.assertEqual(response.context["config"], config)
     self.assertEqual(config.location, TestView.PARIS_LOCATION_JSON)
     self.assertEqual(config.location_user_friendly,
                      TestView.PARIS_LOCATION_USERFRIENDLY)
     self.assertEqual(config.unit, 1)
     self.assertEqual(config.next_performance_date, None)
Exemplo n.º 5
0
 def test_set_location(self):
     c = Client()
     response = c.post("/nabweatherd/settings",
                       {"location": TestView.NYC_LOCATION_JSON})
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.templates[0].name,
                      "nabweatherd/settings.html")
     self.assertTrue("config" in response.context)
     config = Config.load()
     self.assertEqual(response.context["config"], config)
     self.assertEqual(config.location, TestView.NYC_LOCATION_JSON)
     self.assertEqual(config.location_user_friendly,
                      "New York City - New York - US")
     self.assertEqual(config.next_performance_date, None)
     self.assertEqual(config.next_performance_type, None)
Exemplo n.º 6
0
 def setUp(self):
     Config.load()