def test_stats_render(self): yield self.prepare_stats() html = yield stats.render_stats() # print(html) self.assertTrue("Number of clients" in html, "HTML should contain number of clients") self.assertTrue("../static/graphs/hourly.svg" in html, "HTML should contain path to hourly graph") self.assertFalse("127.0.0.1" in html, "HTML should not contain reported ip addresses") self.assertEqual(html.count("192.168.1.1"), 2, "HTML should contain ip address of hosts in tables")
def test_stats_render(self): yield self.prepare_stats() html = yield stats.render_stats() #print(html) self.assertTrue("Number of clients" in html, "HTML should contain number of clients") self.assertTrue("../static/graphs/hourly.svg" in html, "HTML should contain path to hourly graph") self.assertFalse("127.0.0.1" in html, "HTML should not contain reported ip addresses") self.assertEqual(html.count("192.168.1.1"), 2, "HTML should contain ip address of hosts in tables")
def test_empty_state(self): self.stats_settings() yield stats.update_stats_cache() self.assertIsNotNone(stats._cache, "Stats for empty database should not be None") cached = stats._cache["stats"] self.assertEqual(cached["num_hosts"], 0, "Number of hosts in empty database") self.assertEqual(cached["num_reports"], 0, "Number of reports in empty database") self.assertEqual(cached["num_clients"], 0, "Number of clients in empty database") html = yield stats.render_stats() # print(html) self.assertTrue("Number of clients" in html, "HTML should contain number of clients") self.assertTrue("../static/graphs/hourly.svg" in html, "HTML should contain path to hourly graph")
def test_empty_state(self): self.stats_settings() yield stats.update_stats_cache() self.assertIsNotNone(stats._cache, "Stats for empty database should not be None") cached = stats._cache["stats"] self.assertEqual(cached["num_hosts"], 0, "Number of hosts in empty database") self.assertEqual(cached["num_reports"], 0, "Number of reports in empty database") self.assertEqual(cached["num_clients"], 0, "Number of clients in empty database") html = yield stats.render_stats() #print(html) self.assertTrue("Number of clients" in html, "HTML should contain number of clients") self.assertTrue("../static/graphs/hourly.svg" in html, "HTML should contain path to hourly graph")