Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REVIEW] 499 - Flake8 linter #501

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/config/test_settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from config.settings import *
from config.settings import * # noqa F403 F401

DEFAULT_FILE_STORAGE = "inmemorystorage.InMemoryStorage"
10 changes: 9 additions & 1 deletion src/core/serializers/artworks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@
class ArtworkSerializer(ModelSerializer):
class Meta:
model = Artwork
fields = ("id", "author", "marker", "augmented", "title", "description", "created_at")
fields = (
"id",
"author",
"marker",
"augmented",
"title",
"description",
"created_at",
)
read_only_fields = (
"id",
"uploaded_at",
Expand Down
12 changes: 11 additions & 1 deletion src/core/serializers/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@
class ObjectSerializer(ModelSerializer):
class Meta:
model = Object
fields = ("id", "owner", "source", "uploaded_at", "author", "title", "scale", "position", "rotation")
fields = (
"id",
"owner",
"source",
"uploaded_at",
"author",
"title",
"scale",
"position",
"rotation",
)
read_only_fields = (
"id",
"uploaded_at",
Expand Down
17 changes: 10 additions & 7 deletions src/core/tests/test_artworks_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
from django.core.files.uploadedfile import SimpleUploadedFile
from django.test import TestCase

from core.models import Artwork
from core.serializers.artworks import ArtworkSerializer
from core.models import Marker
from core.models import Object
from core.models import Artwork, Marker, Object
from users.models import User

fake_file = SimpleUploadedFile("fake_file.png", b"these are the file contents!")
Expand All @@ -30,7 +27,10 @@ def test_url(self):
def test_api_artworks_lists_one_artwork(self):
marker = Marker.objects.create(owner=self.profile, source=fake_file)
obj = Object.objects.create(owner=self.profile, source=fake_file)
artwork = Artwork.objects.create(author=self.profile, augmented=obj, marker=marker)
artwork = Artwork.objects.create(
author=self.profile, augmented=obj, marker=marker
)
self.assertEqual(artwork.author, self.profile)
response = self.client.get("/api/v1/artworks/")
self.assertEqual(response.status_code, 200)

Expand All @@ -46,7 +46,10 @@ def test_api_artwork_lists_multiple_artworks(self):
def test_retrieve_artwork(self):
marker = Marker.objects.create(owner=self.profile, source=fake_file)
obj = Object.objects.create(owner=self.profile, source=fake_file)
artwork = Artwork.objects.create(author=self.profile, augmented=obj, marker=marker)
artwork = Artwork.objects.create(
author=self.profile, augmented=obj, marker=marker
) # noqa F841
self.assertEqual(artwork.author, self.profile)

response = self.client.get("/api/v1/artworks/1/")
self.assertEqual(response.status_code, 200)

23 changes: 13 additions & 10 deletions src/core/tests/test_exhibits_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
from django.core.files.uploadedfile import SimpleUploadedFile
from django.test import TestCase

from core.models import Artwork
from core.models import Exhibit
from core.models import Marker
from core.models import Object
from core.models import Artwork, Exhibit, Marker, Object
from users.models import User

fake_file = SimpleUploadedFile("fake_file.png", b"these are the file contents!")
Expand All @@ -30,7 +27,9 @@ def test_url(self):
def test_api_exhibits_lists_one_exhibit(self):
marker = Marker.objects.create(owner=self.profile, source=fake_file)
obj = Object.objects.create(owner=self.profile, source=fake_file)
artwork = Artwork.objects.create(author=self.profile, augmented=obj, marker=marker)
artwork = Artwork.objects.create(
author=self.profile, augmented=obj, marker=marker
)
exhibit = Exhibit.objects.create(owner=self.profile, name="test")
exhibit.artworks.add(artwork)
response = self.client.get("/api/v1/artworks/")
Expand All @@ -40,18 +39,22 @@ def test_api_exhibit_lists_multiple_exhibits(self):
for i in range(0, settings.PAGE_SIZE + 1):
marker = Marker.objects.create(owner=self.profile, source=fake_file)
obj = Object.objects.create(owner=self.profile, source=fake_file)
artwork = Artwork.objects.create(author=self.profile, augmented=obj, marker=marker)
exhibit = Exhibit.objects.create(owner=self.profile, name=f'name_{i}', slug=f'slug_{i}')

artwork = Artwork.objects.create(
author=self.profile, augmented=obj, marker=marker
) # noqa F841
exhibit = Exhibit.objects.create(
owner=self.profile, name=f"name_{i}", slug=f"slug_{i}"
) # noqa F841
response = self.client.get("/api/v1/exhibits/")
self.assertEqual(response.status_code, 200)

def test_retrieve_exhibit(self):
marker = Marker.objects.create(owner=self.profile, source=fake_file)
obj = Object.objects.create(owner=self.profile, source=fake_file)
artwork = Artwork.objects.create(author=self.profile, augmented=obj, marker=marker)
artwork = Artwork.objects.create(
author=self.profile, augmented=obj, marker=marker
)
exhibit = Exhibit.objects.create(owner=self.profile, name="test")
exhibit.artworks.add(artwork)
response = self.client.get("/api/v1/exhibits/1/")
self.assertEqual(response.status_code, 200)

4 changes: 2 additions & 2 deletions src/core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
from django.urls import include, path
from rest_framework_nested.routers import DefaultRouter

from core.views.markers import MarkerViewset
from core.views.objects import ObjectViewset
from core.views.artworks import ArtworkViewset
from core.views.exhibits import ExhibitViewset
from core.views.markers import MarkerViewset
from core.views.objects import ObjectViewset
from core.views.static_views import (
community,
documentation,
Expand Down