Commit 53a79ed1 authored by and's avatar and
Browse files

Removed Docstrings And Comments

Removed some unnecessary docstrings and all comments from files in backend.
parent 1167dfca
Pipeline #129128 passed with stage
in 1 minute and 3 seconds
from django.contrib import admin
# Register your models here.
from .models import Comment
admin.site.register(Comment)
......@@ -4,7 +4,6 @@ from django.db import models
from workouts.models import Workout
# Create your models here.
class Comment(models.Model):
"""Django model for a comment left on a workout.
......
......@@ -63,7 +63,6 @@ def create_user(username):
def create_exercises(amount):
# create >10 exercise types for pagination testing
exerciseSerializer = ExerciseSerializer()
for i in range(amount):
valid_data = create_exercise_data(
......
......@@ -14,8 +14,6 @@ webdriver_path = os.environ.get("WEBDRIVER", "chromedriver")
class Visibility(str, enum.Enum):
"""Enum representing workout visibility."""
PUBLIC = "PU"
COACH = "CO"
PRIVATE = "PR"
......@@ -102,7 +100,6 @@ class BlackBoxTestServer(LiveServerTestCase):
self.driver.get(url)
def login(self, user: LoginData):
"""Log in a user and wait until redirected to the workouts page."""
self.get("login.html")
self.assertEqual("Login", self.driver.title)
username_input = self.driver.find_element_by_name("username")
......@@ -113,7 +110,6 @@ class BlackBoxTestServer(LiveServerTestCase):
self.wait.until(lambda driver: driver.title == "Workouts")
def logout(self):
"""Log out a user and wait until redirected to the home page."""
self.get("logout.html")
self.assertEqual("Logout", self.driver.title)
self.wait.until(lambda driver: driver.title == "Home")
......@@ -37,7 +37,7 @@ class FilterWorkoutsTest(BlackBoxTestServer):
self.login(user)
self.get("workouts.html")
self.assertEqual("Workouts", self.driver.title)
time.sleep(2) # :)
time.sleep(2)
self.get_input_value(By.ID, "filter-exercise")
options = self.driver.find_elements_by_tag_name("option")
self.assertEqual(len(options), 3)
......@@ -49,7 +49,7 @@ class FilterWorkoutsTest(BlackBoxTestServer):
self.login(user)
self.get("workouts.html")
self.assertEqual("Workouts", self.driver.title)
time.sleep(2) # :)
time.sleep(2)
options = self.driver.find_elements_by_class_name("workout")
self.assertEqual(len(options), 5)
select = Select((self.driver.find_element_by_id("filter-exercise")))
......
......@@ -37,7 +37,7 @@ class FilterWorkoutsTest(BlackBoxTestServer):
self.login(user)
self.get("highscores.html")
self.assertEqual("Highscores", self.driver.title)
time.sleep(2) # :)
time.sleep(2)
highscores = self.driver.find_elements_by_css_selector("#highscore-content>tr")
self.assertEqual(len(highscores), 2)
......@@ -46,7 +46,7 @@ class FilterWorkoutsTest(BlackBoxTestServer):
self.login(user)
self.get("highscores.html")
self.assertEqual("Highscores", self.driver.title)
time.sleep(2) # :)
time.sleep(2)
highscores = self.driver.find_elements_by_css_selector("#highscore-content>tr")
self.assertEqual(highscores[0].text, "1 arya 2")
self.assertEqual(highscores[1].text, "2 syrio 1")
......@@ -56,7 +56,7 @@ class FilterWorkoutsTest(BlackBoxTestServer):
self.login(user)
self.get("highscores.html")
self.assertEqual("Highscores", self.driver.title)
time.sleep(2) # :)
time.sleep(2)
select = Select((self.driver.find_element_by_id("filter-exercise")))
select.select_by_visible_text("Fencing")
time.sleep(2)
......
......@@ -29,7 +29,6 @@ class ViewProfileTest(BlackBoxTestServer):
return element.get_attribute("value")
def test_non_user_can_not_view_own_profile(self):
"""Test if a user is able to view their own public workout."""
self.get("profile.html")
self.assertEqual("My Profile", self.driver.title)
self.wait_until_value_not_empty(By.ID, "username")
......@@ -41,7 +40,6 @@ class ViewProfileTest(BlackBoxTestServer):
self.assertEqual(email, "")
def test_user_can_view_own_profile(self):
"""Test if a user is able to view their own public workout."""
user = login_data["athlete"]
self.login(user)
self.get("profile.html")
......
......@@ -52,7 +52,6 @@ class ViewWorkoutTest(BlackBoxTestServer):
return element.get_attribute("value")
def test_user_can_view_own_public_workout(self):
"""Test if a user is able to view their own public workout."""
user = login_data["athlete"]
self.login(user)
self.get("workout.html", id=1)
......@@ -68,7 +67,6 @@ class ViewWorkoutTest(BlackBoxTestServer):
self.assertEqual(value, Visibility.PUBLIC)
def test_coach_can_view_athletes_workout(self):
"""Test if a coach is able to view their athlete's workout."""
user = login_data["coach"]
self.login(user)
self.get("workout.html", id=2)
......@@ -83,7 +81,6 @@ class ViewWorkoutTest(BlackBoxTestServer):
self.assertEqual(value, Visibility.COACH)
def test_user_can_view_others_public_workout(self):
"""Test if a user is able to view another users' public workout."""
user = login_data["athlete"]
self.login(user)
self.get("workout.html", id=3)
......@@ -98,7 +95,6 @@ class ViewWorkoutTest(BlackBoxTestServer):
self.assertEqual(value, Visibility.PUBLIC)
def test_user_can_view_own_private_workout(self):
"""Test if a user is able to view their own private workout."""
user = login_data["athlete"]
self.login(user)
self.get("workout.html", id=4)
......@@ -113,7 +109,6 @@ class ViewWorkoutTest(BlackBoxTestServer):
self.assertEqual(value, Visibility.PRIVATE)
def test_user_cannot_view_other_users_private_workout(self):
"""Test if a user is unable to view another users' private workout."""
user = login_data["coach"]
self.login(user)
self.get("workout.html", id=4)
......
......@@ -4,7 +4,6 @@ from django.db import models
class User(AbstractUser):
"""Standard Django User model with an added field for a user's coach."""
coach = models.ForeignKey(
"self", on_delete=models.CASCADE, related_name="athletes", blank=True, null=True
......
"""Module for registering models from workouts app to admin page so that they
appear."""
from django.contrib import admin
from .models import Exercise
......
"""AppConfig for workouts app."""
from django.apps import AppConfig
......
"""Mixins for the workouts application."""
class CreateListModelMixin(object):
"""Mixin that allows to create multiple objects from lists.
......
"""Contains the models for the workouts Django application.
Users log workouts (Workout), which contain instances (ExerciseInstance)
of various type of exercises (Exercise). The user can also upload files
(WorkoutFile) .
"""
import functools
import os
from dataclasses import dataclass
......@@ -18,10 +12,7 @@ from django.db import models
class OverwriteStorage(FileSystemStorage):
"""Filesystem storage for overwriting files.
Currently unused.
"""
"""Filesystem storage for overwriting files."""
def get_available_name(self, name, max_length=None):
"""https://djangosnippets.org/snippets/976/ Returns a filename that's
......
"""Contains custom parsers for serializers from the workouts Django app."""
import json
from rest_framework import parsers
......
"""Contains custom DRF permissions classes for the workouts app."""
from rest_framework import permissions
from workouts.models import Workout
......
"""Serializers for the workouts application."""
from rest_framework import serializers
from rest_framework.serializers import HyperlinkedRelatedField
......
"""Tests for the workouts application."""
from django.test import RequestFactory
from django.test import TestCase
......@@ -13,11 +12,9 @@ from workouts.permissions import IsReadOnly
from workouts.permissions import IsWorkoutPublic
# Create your tests here.
class PermissionTests(TestCase):
@classmethod
def setUpTestData(cls):
# Set up non-modified objects used by all test methods
User.objects.create(password="test123", username="test@gmail.com")
User.objects.create(password="testing1234", username="testing@gmail.com")
user = User.objects.get(id=1)
......@@ -56,7 +53,6 @@ class PermissionTests(TestCase):
)
def setUp(self):
# Setup run before every test method.
self.user1 = User.objects.get(id=1)
self.user2 = User.objects.get(id=2)
self.coach = User.objects.get(id=3)
......
"""Contains views for the workouts application.
These are mostly class-based views.
"""
from operator import attrgetter
from django.db.models import Q
......
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