-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcreate_test_data.py
More file actions
51 lines (41 loc) · 1.36 KB
/
create_test_data.py
File metadata and controls
51 lines (41 loc) · 1.36 KB
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
44
45
46
47
48
49
50
51
import json
import names
import jwt
import uuid
import os
import random
import string
import logging
from utilities.hash_utilities import generate_hash
def create_users() -> list:
try:
logging.info("Creating test users.")
data = []
for i in range(10):
data.append({
'user':names.get_full_name(),
'password':generate_hash(f'12{i}45'),
'token': str(uuid.uuid4())
})
return data
except Exception as e:
logging.exception(f"Exception raised while creating users: {e}")
return []
def create_songs() -> list:
try:
logging.info("Creating test songs.")
data = []
yt_base = "https://www.youtube.com/watch?v="
letters = string.ascii_letters
genres = [ 'Rock', 'HipHop', 'Metal', 'Pop', 'RnB' ]
for i in range(10):
yt_link = yt_base + ''.join(random.choice(letters) for i in range(10))
artist = names.get_first_name()
song_name = names.get_last_name()
genre = random.choice(genres)
token = str(uuid.uuid4())
data.append({ 'song_name': song_name, 'artist': artist, 'genre': genre, 'yt_link': yt_link, 'token': token })
return data
except Exception as e:
logging.exception(f"Error happened while creating test songs: {e}")
return []