Giuseppe Vallarelli has posted comments on this change.
Change subject: Functional Tests [2/3]: Added ipwrapper.ruleExists+routeExists ......................................................................
Patch Set 3: Code-Review-1
(4 comments)
.................................................... File lib/vdsm/ipwrapper.py Line 105: def __iter__(self): Line 106: for word in str(self).split(): Line 107: yield word Line 108: Line 109: def __eq__(self, other): I see that you define the same couple of methods __eq__ and __ne__ for two objects Route and Rule. You can create a class decorator to avoid this duplication here's an example:
In [9]: def equals(cls): def __eq__(self, other): return self.__dict__ == other.__dict__ cls.__eq__ = __eq__ return cls
In [10]: @equals class Pippo(object): def __init__(self, a, b): self.a = a self.b = b ....:
In [11]: c = Pippo(1, 2)
In [12]: d = Pippo(3, 4)
In [13]: c == d Out[13]: False
In [14]: e = Pippo(1, 2)
In [15]: c == e Out[15]: True Line 110: return self.__dict__ == other.__dict__ Line 111: Line 112: def __ne__(self, other): Line 113: return not self.__eq__(other)
.................................................... File tests/functional/networkTests.py Line 410: @RequireDummyMod Line 411: @ValidateRunningAsRoot Line 412: def testRuleExists(self): Line 413: with dummyIf(1) as nics: Line 414: nic = nics[0] I anticipate Toni by saying nic, = nics Line 415: dummy.setIP(nic, IP_ADDRESS, IP_CIDR) Line 416: dummy.setLinkUp(nic) Line 417: Line 418: rules = [Rule(source=IP_NETWORK_AND_CIDR, table=IP_TABLE),
Line 428: @RequireDummyMod Line 429: @ValidateRunningAsRoot Line 430: def testRouteExists(self): Line 431: with dummyIf(1) as nics: Line 432: nic = nics[0] Same as previously stated. Line 433: dummy.setIP(nic, IP_ADDRESS, IP_CIDR) Line 434: dummy.setLinkUp(nic) Line 435: Line 436: routes = [Route(network='0.0.0.0/0', ipaddr=IP_GATEWAY,
.................................................... File tests/functional/utils.py Line 79: raise Line 80: return wrapper Line 81: Line 82: Line 83: def saveRules(): Can you use ipwrapper.ruleList also in cleanupRules as you did in restoreRules?
When I've read saveRules() with ipwrapper.ruleList() in the implementation I've been a little surprised. Line 84: return ipwrapper.ruleList() Line 85: Line 86: Line 87: def restoreRules(base):