mirror of https://github.com/snachodog/mybuddy.git
Format code
This commit is contained in:
parent
94bc12973a
commit
90e16431b8
|
@ -227,7 +227,10 @@ class TimerSerializer(CoreModelSerializer):
|
|||
required=False,
|
||||
)
|
||||
user = serializers.PrimaryKeyRelatedField(
|
||||
allow_null=True, allow_empty=True, queryset=get_user_model().objects.all(), required=False
|
||||
allow_null=True,
|
||||
allow_empty=True,
|
||||
queryset=get_user_model().objects.all(),
|
||||
required=False,
|
||||
)
|
||||
|
||||
class Meta:
|
||||
|
|
|
@ -11,7 +11,9 @@ class Command(migrate.Command):
|
|||
|
||||
superusers = get_user_model().objects.filter(is_superuser=True)
|
||||
if len(superusers) == 0:
|
||||
default_user = get_user_model().objects.create_user("admin", password="admin")
|
||||
default_user = get_user_model().objects.create_user(
|
||||
"admin", password="admin"
|
||||
)
|
||||
default_user.is_superuser = True
|
||||
default_user.is_staff = True
|
||||
default_user.save()
|
||||
|
|
|
@ -9,7 +9,9 @@ from core.models import Child
|
|||
class CommandsTestCase(TransactionTestCase):
|
||||
def test_migrate(self):
|
||||
call_command("migrate", verbosity=0)
|
||||
self.assertIsInstance(get_user_model().objects.get(username="admin"), get_user_model())
|
||||
self.assertIsInstance(
|
||||
get_user_model().objects.get(username="admin"), get_user_model()
|
||||
)
|
||||
|
||||
def test_fake(self):
|
||||
call_command("migrate", verbosity=0)
|
||||
|
@ -20,7 +22,9 @@ class CommandsTestCase(TransactionTestCase):
|
|||
|
||||
def test_reset(self):
|
||||
call_command("reset", verbosity=0, interactive=False)
|
||||
self.assertIsInstance(get_user_model().objects.get(username="admin"), get_user_model())
|
||||
self.assertIsInstance(
|
||||
get_user_model().objects.get(username="admin"), get_user_model()
|
||||
)
|
||||
self.assertEqual(Child.objects.count(), 1)
|
||||
|
||||
def test_createuser(self):
|
||||
|
@ -31,9 +35,13 @@ class CommandsTestCase(TransactionTestCase):
|
|||
password="test",
|
||||
verbosity=0,
|
||||
)
|
||||
self.assertIsInstance(get_user_model().objects.get(username="test"), get_user_model())
|
||||
self.assertIsInstance(
|
||||
get_user_model().objects.get(username="test"), get_user_model()
|
||||
)
|
||||
self.assertFalse(
|
||||
get_user_model().objects.filter(username="test", is_staff=True, is_superuser=True)
|
||||
get_user_model().objects.filter(
|
||||
username="test", is_staff=True, is_superuser=True
|
||||
)
|
||||
)
|
||||
call_command(
|
||||
"createuser",
|
||||
|
@ -43,7 +51,11 @@ class CommandsTestCase(TransactionTestCase):
|
|||
password="test",
|
||||
verbosity=0,
|
||||
)
|
||||
self.assertIsInstance(get_user_model().objects.get(username="testadmin"), get_user_model())
|
||||
self.assertTrue(
|
||||
get_user_model().objects.filter(username="testadmin", is_staff=True, is_superuser=True)
|
||||
self.assertIsInstance(
|
||||
get_user_model().objects.get(username="testadmin"), get_user_model()
|
||||
)
|
||||
self.assertTrue(
|
||||
get_user_model().objects.filter(
|
||||
username="testadmin", is_staff=True, is_superuser=True
|
||||
)
|
||||
)
|
||||
|
|
|
@ -24,7 +24,9 @@ class FormsTestCase(TestCase):
|
|||
"username": fake_user["username"],
|
||||
"password": fake.password(),
|
||||
}
|
||||
cls.user = get_user_model().objects.create_user(is_superuser=True, **cls.credentials)
|
||||
cls.user = get_user_model().objects.create_user(
|
||||
is_superuser=True, **cls.credentials
|
||||
)
|
||||
|
||||
cls.settings_template = {
|
||||
"first_name": "User",
|
||||
|
@ -95,7 +97,9 @@ class FormsTestCase(TestCase):
|
|||
|
||||
page = self.c.post("/users/{}/delete/".format(new_user.id))
|
||||
self.assertEqual(page.status_code, 302)
|
||||
self.assertQuerysetEqual(get_user_model().objects.filter(username="username"), [])
|
||||
self.assertQuerysetEqual(
|
||||
get_user_model().objects.filter(username="username"), []
|
||||
)
|
||||
|
||||
def test_user_settings(self):
|
||||
self.c.login(**self.credentials)
|
||||
|
@ -110,7 +114,9 @@ class FormsTestCase(TestCase):
|
|||
def test_user_regenerate_api_key(self):
|
||||
self.c.login(**self.credentials)
|
||||
|
||||
api_key_before = get_user_model().objects.get(pk=self.user.id).settings.api_key()
|
||||
api_key_before = (
|
||||
get_user_model().objects.get(pk=self.user.id).settings.api_key()
|
||||
)
|
||||
|
||||
params = self.settings_template.copy()
|
||||
params["api_key_regenerate"] = "Regenerate"
|
||||
|
|
|
@ -26,7 +26,9 @@ class FormsTestCaseBase(TestCase):
|
|||
|
||||
fake_user = fake.simple_profile()
|
||||
credentials = {"username": fake_user["username"], "password": fake.password()}
|
||||
cls.user = get_user_model().objects.create_user(is_superuser=True, **credentials)
|
||||
cls.user = get_user_model().objects.create_user(
|
||||
is_superuser=True, **credentials
|
||||
)
|
||||
cls.c.login(**credentials)
|
||||
|
||||
cls.child = models.Child.objects.create(
|
||||
|
|
|
@ -25,7 +25,9 @@ class ViewsTestCase(TestCase):
|
|||
"username": fake_user["username"],
|
||||
"password": fake.password(),
|
||||
}
|
||||
cls.user = get_user_model().objects.create_user(is_superuser=True, **cls.credentials)
|
||||
cls.user = get_user_model().objects.create_user(
|
||||
is_superuser=True, **cls.credentials
|
||||
)
|
||||
|
||||
cls.c.login(**cls.credentials)
|
||||
|
||||
|
|
|
@ -23,7 +23,9 @@ class ViewsTestCase(TestCase):
|
|||
"username": fake_user["username"],
|
||||
"password": fake.password(),
|
||||
}
|
||||
cls.user = get_user_model().objects.create_user(is_superuser=True, **cls.credentials)
|
||||
cls.user = get_user_model().objects.create_user(
|
||||
is_superuser=True, **cls.credentials
|
||||
)
|
||||
|
||||
cls.c.login(**cls.credentials)
|
||||
|
||||
|
|
|
@ -24,7 +24,9 @@ class ViewsTestCase(TestCase):
|
|||
"username": fake_user["username"],
|
||||
"password": fake.password(),
|
||||
}
|
||||
cls.user = get_user_model().objects.create_user(is_superuser=True, **cls.credentials)
|
||||
cls.user = get_user_model().objects.create_user(
|
||||
is_superuser=True, **cls.credentials
|
||||
)
|
||||
|
||||
cls.c.login(**cls.credentials)
|
||||
|
||||
|
|
Loading…
Reference in New Issue