-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathref-users.py
44 lines (38 loc) · 1.46 KB
/
ref-users.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import csv
from people import workspace_users, get_user_channels
def _read():
with open('users.csv', 'r') as f:
return [row for row in csv.DictReader(f)]
users = _read()
# hackathons and roles identified by reference users.csv
hackathons = set([user['hackathon_id'] for user in users])
roles = set([user['role'] for user in users])
print(f'{hackathons = }')
print(f'{roles = }')
# verify user IDs are unique across reference users.csv
by_user = {} # user ID -> user object
for user in users:
id = user['id']
assert id not in by_user
by_user[id] = user
# validate hackathon users
assert hackathons == {'hackthecrisis', 'hackthecrisisafghanistan', 'hackthecrisisindia', 'TGH'}
tgh_workspace = 'theglobalhack'
def _validate_hackathon(hackathon, workspace):
reference_hackathon_users = [id for id, user in by_user.items() \
if user['hackathon_id'] == hackathon]
from_dataset = workspace_users(workspace) # user ID -> list of channels
try:
assert set(from_dataset.keys()) == set(reference_hackathon_users)
except AssertionError:
X = set(from_dataset.keys())
R = set(reference_hackathon_users)
print(
hackathon,
f'{len(X - R) = }', X - R if len(X - R) <= 10 else '...',
f'{len(R - X) = }', R - X if len(R - X) <= 10 else '...',
)
for hackathon in hackathons:
if hackathon == 'TGH':
continue
_validate_hackathon(hackathon, hackathon)