Use enums to describe target WPS state.
To avoid confusion about wps = True/False/None. Came about because of #130
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from .dependency import Dependency
|
||||
from ..model.target import WPSState
|
||||
from ..util.process import Process
|
||||
import json
|
||||
|
||||
@@ -53,11 +54,11 @@ class Wash(Dependency):
|
||||
for t in targets:
|
||||
target_bssid = t.bssid.upper()
|
||||
if target_bssid in wps_bssids:
|
||||
t.wps = True
|
||||
t.wps = WPSState.UNLOCKED
|
||||
elif target_bssid in locked_bssids:
|
||||
t.wps = None
|
||||
t.wps = WPSState.LOCKED
|
||||
else:
|
||||
t.wps = False
|
||||
t.wps = WPSState.NONE
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
@@ -80,7 +81,8 @@ if __name__ == '__main__':
|
||||
# Should update 'wps' field of a target
|
||||
Wash.check_for_wps_and_update_targets(test_file, targets)
|
||||
|
||||
print('Target(BSSID={}).wps = {} (Expected: True)'.format(targets[0].bssid, targets[0].wps))
|
||||
print('Target(BSSID={}).wps = {} (Expected: 1)'.format(
|
||||
targets[0].bssid, targets[0].wps))
|
||||
|
||||
assert targets[0].wps == True
|
||||
assert targets[0].wps == WPSState.UNLOCKED
|
||||
|
||||
|
||||
Reference in New Issue
Block a user