from django.contrib.auth.models import User from companions.models import DesiredMate, Personality, PersonalityDesiredMate, MatingSeason, Companion, RepresentCompanion, Profile, Like, Proposal, Message import promtest import json import requests print("MAKE SUPERUSER") superuser = User.objects.create_user('vaseline', password='******') superuser.is_superuser = True superuser.is_staff = True superuser.save() print("superuser's username : vaseline") print("superuser's password : vaseline") N = 100 print("---------------") for (username, pwd) in promtest.create_users(N): print("\t{0}'s password : "******"\tCreated user {0}".format(username)) for (affinity_with_human, affinity_with_dog, shyness, activity, loudness, aggression, etc) in promtest.create_personality(2 * N + 1): personality = Personality.objects.create( affinity_with_human=affinity_with_human, affinity_with_dog=affinity_with_dog, shyness=shyness, activity=activity, loudness=loudness, aggression=aggression, etc=etc)
res = requests.put(link) if res.status_code != 403: print("ERROR: Should not be allowed to {0} {1} with no auth : code {2}".format(method, link, res.status_code)) exit(1) except Exception: print("ERROR: Cannot get {0}".format(link)) exit(1) def check_key(prom_json, key): if key not in prom_json: print("{0} not in {1}.".format((key, prom_json))) exit(1) userN = 10 user_pairs = promtest.create_users(userN) # get id of each user print("1. Getting users list.") users_json = get_json_or_error("http://localhost:8000/users/") users = [ (uname, upwd, get_id(users_json, uname)) for (uname, upwd) in user_pairs ] print(users) print("******************************************************************************************************************") # remove existing proms print("2. Checking GET http://localhost:8000/promises/") prom_old = get_json_or_error("http://localhost:8000/promises/") print(prom_old) print("******************************************************************************************************************") link = "http://localhost:8000/promises/"