From eae48e4e04fab6e602ded374963999a7962ff5a3 Mon Sep 17 00:00:00 2001 From: Oliver Sauder Date: Mon, 12 Dec 2022 22:18:28 +0400 Subject: [PATCH] Removed obsolete tests * Format keys/field names is extensively tested in test_utils * Testing factories simply tests functionality of another library but nothing DJA specific --- example/tests/test_format_keys.py | 69 ---------------------------- example/tests/unit/test_factories.py | 47 ------------------- 2 files changed, 116 deletions(-) delete mode 100644 example/tests/test_format_keys.py delete mode 100644 example/tests/unit/test_factories.py diff --git a/example/tests/test_format_keys.py b/example/tests/test_format_keys.py deleted file mode 100644 index d0e36d81..00000000 --- a/example/tests/test_format_keys.py +++ /dev/null @@ -1,69 +0,0 @@ -from django.contrib.auth import get_user_model -from django.urls import reverse -from django.utils import encoding -from rest_framework import status - -from example.tests import TestBase - - -class FormatKeysSetTests(TestBase): - """ - Test that camelization and underscoring of key names works if they are activated. - """ - - list_url = reverse("user-list") - - def setUp(self): - super().setUp() - self.detail_url = reverse("user-detail", kwargs={"pk": self.miles.pk}) - - def test_camelization(self): - """ - Test that camelization works. - """ - response = self.client.get(self.list_url) - self.assertEqual(response.status_code, 200) - - user = get_user_model().objects.all()[0] - expected = { - "data": [ - { - "type": "users", - "id": encoding.force_str(user.pk), - "attributes": { - "firstName": user.first_name, - "lastName": user.last_name, - "email": user.email, - }, - } - ], - "links": { - "first": "http://testserver/identities?page%5Bnumber%5D=1", - "last": "http://testserver/identities?page%5Bnumber%5D=2", - "next": "http://testserver/identities?page%5Bnumber%5D=2", - "prev": None, - }, - "meta": {"pagination": {"page": 1, "pages": 2, "count": 2}}, - } - - assert expected == response.json() - - -def test_options_format_field_names(db, client): - response = client.options(reverse("author-list")) - assert response.status_code == status.HTTP_200_OK - data = response.json()["data"] - expected_keys = { - "name", - "fullName", - "email", - "bio", - "entries", - "firstEntry", - "authorType", - "comments", - "secrets", - "defaults", - "initials", - } - assert expected_keys == data["actions"]["POST"].keys() diff --git a/example/tests/unit/test_factories.py b/example/tests/unit/test_factories.py deleted file mode 100644 index ac9d7b2a..00000000 --- a/example/tests/unit/test_factories.py +++ /dev/null @@ -1,47 +0,0 @@ -import pytest - -from example.factories import BlogFactory -from example.models import Blog - -pytestmark = pytest.mark.django_db - - -def test_factory_instance(blog_factory): - - assert blog_factory == BlogFactory - - -def test_model_instance(blog): - - assert isinstance(blog, Blog) - - -def test_multiple_blog(blog_factory): - another_blog = blog_factory(name="Cool Blog") - new_blog = blog_factory(name="Awesome Blog") - - assert another_blog.name == "Cool Blog" - assert new_blog.name == "Awesome Blog" - - -def test_factories_with_relations(author_factory, entry_factory): - - author = author_factory(name="Joel Spolsky") - entry = entry_factory( - headline=( - "The Absolute Minimum Every Software Developer" - "Absolutely, Positively Must Know About Unicode " - "and Character Sets (No Excuses!)" - ), - blog__name="Joel on Software", - authors=(author,), - ) - - assert entry.blog.name == "Joel on Software" - assert entry.headline == ( - "The Absolute Minimum Every Software Developer" - "Absolutely, Positively Must Know About Unicode " - "and Character Sets (No Excuses!)" - ) - assert entry.authors.all().count() == 1 - assert entry.authors.all()[0].name == "Joel Spolsky"