Skip to content

Commit

Permalink
Fuff cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
rh0dium committed Jun 29, 2024
1 parent 669115f commit bb4bbe0
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 30 deletions.
20 changes: 10 additions & 10 deletions datatableview/tests/test_datatables.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class NoError(BaseException):
pass

with self.assertRaises(NoError):
dt = DT([], "/")
DT([], "/")
raise NoError()

def test_column_names_list_raises_related_columns(self):
Expand All @@ -74,7 +74,7 @@ class NoError(BaseException):
pass

with self.assertRaises(NoError):
dt = DT([], "/")
DT([], "/")
raise NoError()

def test_get_ordering_splits(self):
Expand Down Expand Up @@ -148,7 +148,7 @@ def test_get_records_populates_cache(self):

def test_populate_records_searches(self):
obj1 = ExampleModel.objects.create(name="test name 1", value=False)
obj2 = ExampleModel.objects.create(name="test name 2", value=True)
ExampleModel.objects.create(name="test name 2", value=True)
queryset = ExampleModel.objects.all()

class DT(Datatable):
Expand Down Expand Up @@ -195,7 +195,7 @@ class Meta:
self.assertEqual(list(dt._records), [obj2, obj1])

def test_populate_records_avoids_column_callbacks(self):
obj1 = ExampleModel.objects.create(name="test name 1")
ExampleModel.objects.create(name="test name 1")
queryset = ExampleModel.objects.all()

class DT(Datatable):
Expand All @@ -211,7 +211,7 @@ def preload_record_data(self, obj):
raise

def test_preload_record_data_calls_view(self):
obj1 = ExampleModel.objects.create(name="test name 1")
ExampleModel.objects.create(name="test name 1")
queryset = ExampleModel.objects.all()

class Dummy(object):
Expand Down Expand Up @@ -453,7 +453,7 @@ def test_get_object_pk(self):

def test_get_extra_record_data_passes_through_to_object_serialization(self):
obj1 = ExampleModel.objects.create(name="test name 1")
queryset = ExampleModel.objects.all()
ExampleModel.objects.all()

class DT(Datatable):
def get_extra_record_data(self, obj):
Expand All @@ -466,7 +466,7 @@ def get_extra_record_data(self, obj):
self.assertEqual(data["_extra_data"]["custom"], "data")

def test_get_extra_record_data_passes_through_to_json_response(self):
obj1 = ExampleModel.objects.create(name="test name 1")
ExampleModel.objects.create(name="test name 1")
queryset = ExampleModel.objects.all()

class DT(Datatable):
Expand Down Expand Up @@ -672,9 +672,9 @@ class Meta:
self.assertEqual(list(dt._records), [])

def test_search_term_boolean(self):
obj1 = ExampleModel.objects.create(name="test name 1", value=True)
obj2 = ExampleModel.objects.create(name="test name 2", value=True)
obj3 = ExampleModel.objects.create(name="test name 12", value=False)
ExampleModel.objects.create(name="test name 1", value=True)
ExampleModel.objects.create(name="test name 2", value=True)
ExampleModel.objects.create(name="test name 12", value=False)
queryset = ExampleModel.objects.all()

class DT(Datatable):
Expand Down
2 changes: 1 addition & 1 deletion datatableview/tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def test_through_filter(self):
"""Verifies that through_filter works."""
helper = helpers.through_filter

target_function = lambda data, arg=None: (data, arg)
target_function = lambda data, arg=None: (data, arg) # noqa:E731

# Verify simple use
data = "Data string"
Expand Down
24 changes: 12 additions & 12 deletions datatableview/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,40 +135,40 @@ def test_column_backed_by_method_datatable_view(self):
view = ColumnBackedByMethodDatatableView
url = reverse("column-backed-by-method")
view.request = FakeRequest(url)
response = self.client.get(url)
obj = self.get_json_response(url)
self.client.get(url)
self.get_json_response(url)

def test_compound_columns_datatable_view(self):
view = CompoundColumnsDatatableView
url = reverse("compound-columns")
view.request = FakeRequest(url)
response = self.client.get(url)
obj = self.get_json_response(url)
self.client.get(url)
self.get_json_response(url)

def test_many_to_many_fields_datatable_view(self):
view = ManyToManyFieldsDatatableView
url = reverse("many-to-many-fields")
view.request = FakeRequest(url)
response = self.client.get(url)
obj = self.get_json_response(url)
self.client.get(url)
self.get_json_response(url)

def test_default_callback_names_datatable_view(self):
view = DefaultCallbackNamesDatatableView
url = reverse("default-callback-names")
view.request = FakeRequest(url)
response = self.client.get(url)
obj = self.get_json_response(url)
self.client.get(url)
self.get_json_response(url)

def test_helpers_reference_datatable_view(self):
view = HelpersReferenceDatatableView
url = reverse("helpers-reference")
view.request = FakeRequest(url)
response = self.client.get(url)
obj = self.get_json_response(url)
self.client.get(url)
self.get_json_response(url)

def test_satellite_datatable_view(self):
view = SatelliteDatatableView
url = reverse("satellite")
view.request = FakeRequest(url)
response = self.client.get(url)
obj = self.get_json_response(url)
self.client.get(url)
self.get_json_response(url)
12 changes: 6 additions & 6 deletions demo_app/demo_app/settings_test.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# -*- coding: utf-8 -*-

import os
import warnings

from .settings import * # noqa: F403,F401

# Handle system warning as log messages
warnings.simplefilter("once")

for handler in LOGGING.get("handlers", []):
LOGGING["handlers"][handler]["level"] = "CRITICAL"
for logger in LOGGING.get("loggers", []):
LOGGING["loggers"][logger]["level"] = "CRITICAL"
for handler in LOGGING.get("handlers", []): # noqa: F405
LOGGING["handlers"][handler]["level"] = "CRITICAL" # noqa: F405
for logger in LOGGING.get("loggers", []): # noqa: F405
LOGGING["loggers"][logger]["level"] = "CRITICAL" # noqa: F405

mysql_db = DATABASES["default"]
mysql_db = DATABASES["default"] # noqa: F405
DEFAULT_DB = {
"ENGINE": "django.db.backends.sqlite3",
"NAME": ":memory:",
Expand Down
2 changes: 1 addition & 1 deletion demo_app/example_app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def get_context_data(self, **kwargs):
db_works = True
try:
list(Entry.objects.all()[:1])
except:
except Exception:
db_works = False
context["db_works"] = db_works

Expand Down

0 comments on commit bb4bbe0

Please sign in to comment.