示例#1
0
    def test_do_hosts(self):
        fake_request = self.mox.CreateMockAnything()
        host1 = {'host': 'www.demo.com'}
        host2 = {'host': 'www.example.com'}
        hosts = [host1, host2]
        self.mox.StubOutWithMock(stacky_server, 'get_host_names')
        stacky_server.get_host_names().AndReturn(hosts)
        self.mox.ReplayAll()

        resp = stacky_server.do_hosts(fake_request)

        self.assertEqual(resp.status_code, 200)
        json_resp = json.loads(resp.content)
        self.assertEqual(len(json_resp), 3)
        self.assertEqual(json_resp[0], ['Host Name'])
        self.assertEqual(json_resp[1], ['www.demo.com'])
        self.assertEqual(json_resp[2], ['www.example.com'])
        self.mox.VerifyAll()
示例#2
0
    def test_do_hosts(self):
        fake_request = self.mox.CreateMockAnything()
        host1 = {"host": "www.demo.com"}
        host2 = {"host": "www.example.com"}
        hosts = [host1, host2]
        self.mox.StubOutWithMock(stacky_server, "get_host_names")
        stacky_server.get_host_names().AndReturn(hosts)
        self.mox.ReplayAll()

        resp = stacky_server.do_hosts(fake_request)

        self.assertEqual(resp.status_code, 200)
        json_resp = json.loads(resp.content)
        self.assertEqual(len(json_resp), 3)
        self.assertEqual(json_resp[0], ["Host Name"])
        self.assertEqual(json_resp[1], ["www.demo.com"])
        self.assertEqual(json_resp[2], ["www.example.com"])
        self.mox.VerifyAll()
示例#3
0
    def test_get_host_names(self):
        result = self.mox.CreateMockAnything()
        models.RawData.objects.values("host").AndReturn(result)
        result.distinct().AndReturn(result)
        self.mox.ReplayAll()

        event_names = stacky_server.get_host_names()
        self.assertEqual(event_names, result)

        self.mox.VerifyAll()
示例#4
0
    def test_get_host_names(self):
        result = self.mox.CreateMockAnything()
        models.RawData.objects.values('host').AndReturn(result)
        result.distinct().AndReturn(result)
        self.mox.ReplayAll()

        event_names = stacky_server.get_host_names()
        self.assertEqual(event_names, result)

        self.mox.VerifyAll()