2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-15 09:37:10 +00:00

sort imports using isort. tested.

This commit is contained in:
2023-01-19 18:35:56 +00:00
parent 939d3970aa
commit be9fcc522a
26 changed files with 296 additions and 245 deletions

View File

@@ -18,28 +18,30 @@ $ python manage.py test cuy.club --parallel
Runs the tests in this file only
"""
import unittest
import re
from django.test import TestCase, SimpleTestCase, TransactionTestCase, Client
import unittest
from django.test import Client, SimpleTestCase, TestCase, TransactionTestCase
class ImportTest(TestCase):
def test_import_imports(self):
# Need to go through all modules and copy all imports here
ed to go through all modules and copy all imports here
from io import StringIO
from cuy.club.models import (Article, Event, Member, Webpage,
WebpageCategory)
from cuy.website.views.generic import PUBLIC_LOGIN
from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django.core import management
from django.db import connection, connections
from django.http import HttpResponse
from django.db.utils import IntegrityError
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
from django.template.defaultfilters import slugify
from django.utils.timezone import get_current_timezone, make_aware
from io import StringIO
from cuy.club.models import Member, Article, Event, WebpageCategory, Webpage
from cuy.website.views.generic import PUBLIC_LOGIN
from cuy.club.models import Member
from django.db.utils import IntegrityError
class SimpleTest(SimpleTestCase):
@@ -110,9 +112,9 @@ class DataTests(TestCase ):
self.assertIsNotNone(None, "Failed to enforce 'UNIQUE constraint' on saving two Member objects with same user_id")
def test_article_invalid_date(self):
from cuy.club.models import Member, Article
from django.db.utils import IntegrityError
from cuy.club.models import Article, Member
from django.core.exceptions import ValidationError
from django.db.utils import IntegrityError
a = Article()
m = self.member
@@ -126,9 +128,9 @@ class DataTests(TestCase ):
self.assertIsNotNone(t, "Exception is not the expected 'invalid format'")
def test_article_and_author_not_null(self):
from cuy.club.models import Member, Article
from django.db.utils import IntegrityError
from cuy.club.models import Article, Member
from django.core.exceptions import ValidationError
from django.db.utils import IntegrityError
a2 = Article()
a2.publish ="2021-02-17 17:25"
@@ -143,9 +145,9 @@ class DataTests(TestCase ):
self.assertIsNotNone(None, "Exception is not the expected 'NOT NULL constraint failed' IntegrityError")
def test_article_and_author_ok(self):
from cuy.club.models import Member, Article
from django.db.utils import IntegrityError
from cuy.club.models import Article, Member
from django.core.exceptions import ValidationError
from django.db.utils import IntegrityError
m = self.member
a3 = Article()
@@ -201,8 +203,8 @@ class FixturePageTests(TestCase):
def test_fix_admin_login_fail(self):
c = self.client
from django.contrib.auth.models import User
from cuy.club.models import Member
from django.contrib.auth.models import User
m = Member.objects.get(pk=9002)
u = User.objects.get(username='bingo')
@@ -223,7 +225,7 @@ class ComplexLoginTests(TestCase):
'''These test the login and capabilities of logged-in users'''
def setUp(self):
'''setUp runs once for each test in this class'''
from cuy.club.models import Member, MEMBER_TYPES, AFFILIATION
from cuy.club.models import AFFILIATION, MEMBER_TYPES, Member
from django.contrib.auth.models import User
m = Member()
m.pk=8000
@@ -344,6 +346,7 @@ class ComplexLoginTests(TestCase):
def test_committee_login(self):
from django.contrib.auth.models import User
# User must be associated with a Member for whom is_committee() is True
c = self.client # inherited from TestCase
u = self.user
@@ -407,7 +410,7 @@ class DynamicPageTests(TestCase):
def test_full_yachts(self):
'''Creating a WebpageCategory and an index webpage creates a valid url
'''
from cuy.club.models import WebpageCategory, Webpage
from cuy.club.models import Webpage, WebpageCategory
wc = WebpageCategory()
wc.pk = 8000
wc.id = 8000