Commit cc3a99ab authored by Andreasjj's avatar Andreasjj
Browse files

updated tests

parent d6c712c6
......@@ -42,29 +42,12 @@ def get_workout(token, workout_id):
return requests.get("%s/workouts/%d/" % (REST_API_BASE, workout_id), headers=headers).json()
def get_exercises(token):
def get_workouts(token):
headers={
'authorization': "Bearer %s" % token
}
return requests.get("%s/exercises/" % REST_API_BASE, headers=headers).json()
def create_exercise(token, name, description, unit, file):
payload = {
'name': name,
'description': description,
'unit': unit
}
files={
'files': ('file.txt', file)
}
headers={
'authorization': "Bearer %s" % token
}
return requests.post("%s/exercises/" % REST_API_BASE, data=payload, files=files, headers=headers).json()
return requests.get("%s/workouts/" % REST_API_BASE, headers=headers).json()
def add_coach(token, my_id, coach_url):
payload = {
......
......@@ -6,7 +6,7 @@ from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.expected_conditions import presence_of_element_located
from .constants import TEST_ROOT
from .helpers.registration import write_registration_inputs
from .helpers.rest import get_user_tokens, get_exercises, create_exercise
from .helpers.rest import get_user_tokens, get_workouts, create_exercise
from selenium.webdriver.support import expected_conditions as EC
import uuid
......@@ -43,7 +43,7 @@ class InfinityScroll(unittest.TestCase):
# initialization of webdriver
def setUp(self):
firefox_options = webdriver.FirefoxOptions()
firefox_options.add_argument('-headless')
#firefox_options.add_argument('-headless')
firefox_options.add_argument("--width=1920")
firefox_options.add_argument("--height=1080")
self.driver = webdriver.Firefox(firefox_options=firefox_options)
......@@ -52,14 +52,14 @@ class InfinityScroll(unittest.TestCase):
driver.execute_script("window.scrollTo(0, document.body.scrollHeight*0.9);");
def wait_for_exercises(self, driver, count):
locator = (By.XPATH, "//a[contains(@class,'exercise')]")
locator = (By.XPATH, "//a[contains(@class,'workout')]")
condition = ElementsLengthChanges(locator, count)
WebDriverWait(driver, 10).until(condition)
def test(self):
username = str(uuid.uuid4())
# Register user
self.driver.get("%s/register.html" % TEST_ROOT)
self.driver.get("%s/workouts.html" % TEST_ROOT)
write_registration_inputs(
self.driver,
username,
......@@ -75,12 +75,12 @@ class InfinityScroll(unittest.TestCase):
# Check how many exercises there are, if less than 40 then create
# the remaining amount
tokens = get_user_tokens(username, "test")
exercises = get_exercises(tokens['access'])
exercieCount = exercises['count']
if exercieCount < 40:
countToMake = 40 - exercieCount
workouts = get_workouts(tokens['access'])
workoutsCount = workouts['count']
if workoutsCount < 40:
countToMake = 40 - workoutsCount
for i in range(countToMake):
create_exercise(tokens['access'], "test", "test", "test", "file?")
create_workout(tokens['access'], "Test workout(public)", "This is a note", datetime.now(), "PU", "A file!")
# Go to the exercies page
self.driver.get("%s/exercises.html" % TEST_ROOT)
......@@ -96,7 +96,7 @@ class InfinityScroll(unittest.TestCase):
self.wait_for_exercises(self.driver, 40)
elements = self.driver.find_elements(By.XPATH, "//a[contains(@class,'exercise')]")
elements = self.driver.find_elements(By.XPATH, "//a[contains(@class,'workout')]")
assert len(elements) == 40
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment