blob: db9783404c697e123b0fd96c23c31e8d60917e20 [file] [log] [blame]
#!/usr/bin/python
# Copyright 2012 Google Inc. All Rights Reserved.
#
# Disable some checks that aren't important for tests:
#gpylint: disable-msg=E0602,C6409,C6111,C0111
__author__ = 'Avery Pennarun (apenwarr@google.com)'
from wvtest import *
import core
@wvtest
def testConfigCore():
hosts = core.Hosts()
WVPASSEQ(len(hosts), 0)
h = hosts.FindOrAdd(ether='11:22:33:44:55:66')
h.Set(name='testname', ip='1.2.3.4')
h.platform = 'bob'
WVPASSEQ(len(hosts), 1)
h2 = hosts.FindOrAdd(ip='1.2.3.4')
WVPASSEQ(len(hosts), 1)
WVPASSEQ(h2.name, 'testname')
WVPASSEQ(h2.ether, '11:22:33:44:55:66')
WVPASSEQ(h, h2)
# test Host.Query()
WVPASSEQ(hosts.Query(ip=True), [h])
WVPASSEQ(hosts.Query(ip=False), [])
WVPASSEQ(hosts.Query(ip='1.2.3.4'), [h])
WVPASSEQ(hosts.Query(ip='1.2.3.5'), [])
WVPASSEQ(hosts.Query(ip='1.2.3.4', maxcount=0), [])
WVEXCEPT(core.QueryError, hosts.Query, ip='1.2.3.5', mincount=1)