feat(track2): scaffold uneven seeding script with user bootstrap
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Сидирует 100k сообщений в 24 чата с неравномерными размерами (трек 2)."""
|
||||
import base64
|
||||
import sys
|
||||
import uuid
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT / 'tests'))
|
||||
|
||||
from client import Client, arguments, run # noqa: E402
|
||||
|
||||
|
||||
def make_user(c, label):
|
||||
username = f'{label}_{uuid.uuid4().hex[:12]}'
|
||||
password = 'T3st-' + uuid.uuid4().hex
|
||||
user = c.call('POST', '/api/v1/users', 201, body={
|
||||
'username': username, 'display_name': label.capitalize(),
|
||||
'password': password}, schema='User')['json']
|
||||
cred = base64.b64encode(f'{username}:{password}'.encode()).decode()
|
||||
s = c.call('POST', '/api/v1/auth/sessions', 201,
|
||||
headers={'Authorization': 'Basic ' + cred}, schema='Session')['json']
|
||||
return {'id': user['id'], 'username': username, 'token': s['token']}
|
||||
|
||||
|
||||
def main():
|
||||
args = arguments('Сидирует неравномерные чаты для трека 2')
|
||||
c = Client(args.base_url, args.ca_file)
|
||||
alice = make_user(c, 'track2_a')
|
||||
bob = make_user(c, 'track2_b')
|
||||
print(f'alice={alice["id"]} bob={bob["id"]}')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
run(main)
|
||||
Reference in New Issue
Block a user