Skip to content

Commit

Permalink
[#234] Change keyword that server checks for a tester user (#244)
Browse files Browse the repository at this point in the history
* basic search/replace of Tester with iwt, including schema doc

* 234 Black formatting for test_appuser.py

* #234 simplify prefixes list to just "iwt", document case insensitivity

* #234 actually fixing the "iwt-d" test, this time

* #234 changed is_tester logic to tokenize and check for 'iwt' regardless of case

* Add one more test

* Remove unused var

---------

Co-authored-by: Jimmi <jimmih@gmail.com>
Co-authored-by: Francis Li <mail@francisli.com>
  • Loading branch information
3 people authored Sep 12, 2024
1 parent b86ef42 commit a9bdf3d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
5 changes: 3 additions & 2 deletions home/tests/unit/api/test_appuser.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ def test_is_tester(self):
("Iwt A", True),
("Test B", False),
("iwt c", True),
("John Iwt", True),
("Iwterosa", False),
("iwt-d", True),
("Iwt_E", True),
("iwt-d", False),
("Iwt_E", False),
("iwtrata", False),
("iwt", True),
]
Expand Down
11 changes: 6 additions & 5 deletions home/views/api/appuser.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
from .utils import validate_request_json


# Determines whether Account is tester account, based on name prefix
# Determines whether Account is tester account, based on name in label
def is_tester(name_field: str) -> bool:
possible_prefixes = ["iwt "]
return any(
[name_field.lower().startswith(prefix) for prefix in possible_prefixes]
)
parts = name_field.split(" ", 1)
for s in parts:
if "iwt" == s.lower():
return True
return False


# Validates Account input data. Raises AssertionError if field is invalid.
Expand Down

0 comments on commit a9bdf3d

Please sign in to comment.