Skip to content

Commit

Permalink
Function for creating blacklist from STATUS_CHANGES
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksiyVeretiuk committed Oct 3, 2017
1 parent e5dcf09 commit 4f69742
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions openregistry/api/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from openregistry.api.constants import VERSION, SESSION



now = datetime.now()


Expand All @@ -33,6 +34,29 @@ def snitch(func):
'test_' + func.func_name, closure=func.func_closure)


def create_blacklist(status_changes, statuses):
# This cycle generate black list for every status and
# every auth role
status_blacklist = {}
for status in statuses:
status_blacklist[status] = {}
for auth_role in ['lot_owner', 'Administrator', 'convoy', 'concierge']:
status_blacklist[status][auth_role] = []
for w in status_changes[status]['next_status']:
if auth_role in status_changes[status]['next_status'][w]:
status_blacklist[status][auth_role].append(w)
if auth_role in status_changes[status]['editing_permissions']:
status_blacklist[status][auth_role].append(status)
black_list = list(set(statuses) - set(status_blacklist[status][auth_role]))
status_blacklist[status][auth_role] = black_list
if auth_role == 'lot_owner':
status_blacklist[status]['broker'] = status_blacklist[status]['lot_owner']
del status_blacklist[status]['lot_owner']
if auth_role == 'Administrator':
status_blacklist[status]['administrator'] = status_blacklist[status]['Administrator']
del status_blacklist[status]['Administrator']
return status_blacklist

class PrefixedRequestClass(webtest.app.TestRequest):

@classmethod
Expand Down

0 comments on commit 4f69742

Please sign in to comment.