def test_view(self, check_output): check_output.return_value = raw client = Client() response = client.get(reverse("status")) self.assertEqual(response.status_code, 200) output = yaml.load(raw, Loader=yaml.Loader) machines = extract_machines(output) services = extract_services(output) self.assertListEqual(response.context['machines'], machines) self.assertListEqual(response.context['services'], services) check_output.assert_called_with(["juju", "status"])
def test_services(self): output = yaml.load(raw, Loader=yaml.Loader) data = extract_services(output) expected = [ ("cpbr6/3", "started"), ("chicote2/2", "started"), ("zito001/0", "started"), ("tsurudashboard/1", "started"), ("tsurudashboard/2", "started"), ("mysqlapi/1", "started"), ("mysqlapi/2", "started"), ] self.assertListEqual(data, expected)