def test_effectively_equal_different_time(self, entry, timestamp): good_entry = RadiusLogEntry( '00:de:ad:be:ef:00', 'Access-Accept', ['traffic'], [['Egress-VLAN-Name', '"2hades-unauth"']], timestamp - 50, ) assert RadiusLogEntry.effectively_equal(entry, good_entry)
def test_not_effectively_equal_different_group(self, entry, timestamp): bad_entry = RadiusLogEntry( '00:de:ad:be:ef:00', 'Access-Accept', ['violation'], [['Egress-VLAN-Name', '"2hades-unauth"']], timestamp - 50, ) assert not RadiusLogEntry.effectively_equal(entry, bad_entry)
def entry(self, timestamp): return RadiusLogEntry( '00:de:ad:be:ef:00', 'Access-Accept', ['traffic'], [['Egress-VLAN-Name', '"2hades-unauth"']], timestamp, )
def assert_acceptance_from_reply(reply, should_accept=False): entry = RadiusLogEntry(mac=None, reply=reply, groups=None, raw_attributes=None, timestamp=None) if should_accept: assert entry.accepted assert entry else: assert not entry.accepted assert not entry
def entries(self): timestamp = 1501623826.391414 return [ RadiusLogEntry(*e) for e in [ ('00:de:ad:be:ef:00', 'Access-Accept', ['traffic'], [['Egress-VLAN-Name', '"2hades-unauth"']], timestamp), ('00:de:ad:be:ef:00', 'Access-Accept', ['traffic'], [['Egress-VLAN-Name', '"2hades-unauth"']], timestamp - 50), ('00:de:ad:be:ef:00', 'Access-Accept', ['violation'], [['Egress-VLAN-Name', '"2hades-unauth"']], timestamp - 100), ] ]
def test_reflexivity(self, entry): assert RadiusLogEntry.effectively_equal(entry, entry)
def test_comparison_to_incomplete_type_gives_false(self, entry): assert not RadiusLogEntry.effectively_equal(entry, object())
def invalid_entry(raw_entry): invalid_entry = raw_entry.copy() invalid_entry[3][0][1] = '3Invalid' return RadiusLogEntry(*invalid_entry)
def entry(raw_entry): return RadiusLogEntry(*raw_entry)