Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
8146239
Add test _utils; Modify a number of test models
pmishchenko-ua Feb 12, 2025
8d18e7b
fix inspecdb tests
pmishchenko-ua Mar 7, 2025
bdc27a9
Fix expressions tests
pmishchenko-ua Mar 12, 2025
3cf7001
Fix model_forms tests
pmishchenko-ua Mar 13, 2025
528873b
Fix update tests
pmishchenko-ua Mar 13, 2025
8219207
Fix model_formsets tests
pmishchenko-ua Mar 13, 2025
364db77
Fix serializers test models
pmishchenko-ua Mar 27, 2025
0a20f63
Refactor tests
pmishchenko-ua Apr 2, 2025
bdb6062
get_or_create test fix
psharma-1909 Apr 7, 2025
7d9f430
reverting local setup changes
psharma-1909 Apr 7, 2025
0fda7fe
Merge pull request #3 from singlestore-labs/get_or_create_test
pmishchenko-ua Apr 7, 2025
8d121f6
Fix for lookup tests (#2)
pmishchenko-ua Apr 9, 2025
05d7876
Some cleanup for old tests (#4)
pmishchenko-ua Apr 9, 2025
09fe753
fix of update_only_field test (#5)
psharma-1909 Apr 9, 2025
a0a8fbd
Change models for contenttypes_tests (#6)
pmishchenko-ua Apr 10, 2025
1e17946
Change model for test_runner tests (#7)
psharma-1909 Apr 11, 2025
587f8cc
fix of expressions_case tests (#8)
psharma-1909 Apr 11, 2025
6fd4d22
Fix model_fields tests (#9)
pmishchenko-ua Apr 24, 2025
85c0dd5
fix test (#10)
psharma-1909 Apr 25, 2025
446d913
Fix multiple_database tests (#11)
pmishchenko-ua Apr 25, 2025
26a9ccf
known_related_objects test fix (#13)
psharma-1909 May 10, 2025
6a20f50
fix of aggregation_regress tests (#12)
psharma-1909 May 12, 2025
5191ab2
Fix m2m_recursive tests (#14)
pmishchenko-ua May 12, 2025
6ee139e
Run fixtures_regress tests (#15)
pmishchenko-ua May 12, 2025
dad6011
fix of admin_views tests (#16)
psharma-1909 May 13, 2025
ebff167
Fix generic_relations_regress (#17)
psharma-1909 May 13, 2025
42e81c2
Fix utils_tests (#18)
psharma-1909 May 13, 2025
534e2ea
Fix many_to_one_null (#19)
psharma-1909 May 14, 2025
957dc88
Fix of introspection (#20)
psharma-1909 May 15, 2025
d98d68d
Fix of basic tests (#21)
psharma-1909 May 16, 2025
d8cd49e
fix of foreign_object tests (#22)
psharma-1909 May 16, 2025
1b7efcb
Modify models in fixtures tests (#25)
pmishchenko-ua May 16, 2025
46106aa
Fix of constraints tests (#26)
psharma-1909 May 16, 2025
ad242f2
Fix of auth_tests (#27)
psharma-1909 May 19, 2025
d4fdae8
Change models in one_to_one tests (#28)
pmishchenko-ua May 19, 2025
2a7c63b
Fix of admin_script test (#29)
psharma-1909 May 19, 2025
6ef5cf5
Fix of bulk_create tests (#30)
psharma-1909 May 20, 2025
87725d4
Fix for backends tests (#31)
pmishchenko-ua May 22, 2025
31bff40
Run delete tests (#32)
pmishchenko-ua May 23, 2025
f5cdcb2
Fix of db_functions tests (#23)
psharma-1909 Jun 2, 2025
9f40fd7
Fix of migrations tests (#33)
psharma-1909 Jun 11, 2025
92c3073
Cleanup temporary test files (#36)
pmishchenko-ua Jul 9, 2025
7bdc3ca
Psharma/fix tests group0a (#41)
psharma-1909 Jul 31, 2025
c7d3bb5
Psharma/fix tests group1a (#40)
psharma-1909 Jul 31, 2025
54d9d78
Psharma/fix tests group2a (#39)
psharma-1909 Jul 31, 2025
9b8f3b9
Psharma/fix tests group3a (#38)
psharma-1909 Jul 31, 2025
974edfd
Psharma/fix tests group4a (#37)
psharma-1909 Jul 31, 2025
f845bf7
Fix test_proxy_delete (#42)
pmishchenko-ua Aug 19, 2025
a36dc3f
Fix tests involving collation (#43)
pmishchenko-ua Aug 20, 2025
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
11 changes: 10 additions & 1 deletion tests/admin_docs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Person(models.Model):
last_name = models.CharField(max_length=200, help_text="The person's last name")
company = models.ForeignKey(Company, models.CASCADE, help_text="place of work")
family = models.ForeignKey(Family, models.SET_NULL, related_name="+", null=True)
groups = models.ManyToManyField(Group, help_text="has membership")
groups = models.ManyToManyField("Group", help_text="has membership", through="PersonGroup")

def _get_full_name(self):
return "%s %s" % (self.first_name, self.last_name)
Expand Down Expand Up @@ -88,3 +88,12 @@ def get_status_count(self):

def get_groups_list(self):
return []


class PersonGroup(models.Model):
person = models.ForeignKey(Person, on_delete=models.CASCADE)
group = models.ForeignKey(Group, on_delete=models.CASCADE)

class Meta:
unique_together = (('person', 'group'),)
db_table = "admin_docs_person_group"
14 changes: 14 additions & 0 deletions tests/admin_filters/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django_singlestore.schema import ModelStorageManager


class Book(models.Model):
Expand All @@ -20,6 +21,7 @@ class Book(models.Model):
verbose_name="Verbose Contributors",
related_name="books_contributed",
blank=True,
through="BookUser",
)
employee = models.ForeignKey(
"Employee",
Expand Down Expand Up @@ -48,11 +50,15 @@ def __str__(self):
class ImprovedBook(models.Model):
book = models.OneToOneField(Book, models.CASCADE)

objects = ModelStorageManager("ROWSTORE REFERENCE")


class Department(models.Model):
code = models.CharField(max_length=4, unique=True)
description = models.CharField(max_length=50, blank=True, null=True)

objects = ModelStorageManager("ROWSTORE REFERENCE")

def __str__(self):
return self.description

Expand All @@ -64,6 +70,14 @@ class Employee(models.Model):
def __str__(self):
return self.name

class BookUser(models.Model):
book = models.ForeignKey(Book, on_delete=models.CASCADE)
user = models.ForeignKey(User, on_delete=models.CASCADE)

class Meta:
unique_together = (('book', 'user'),)
db_table = "admin_filters_book_user"


class TaggedItem(models.Model):
tag = models.SlugField()
Expand Down
1 change: 0 additions & 1 deletion tests/admin_scripts/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2998,7 +2998,6 @@ def test_unified(self):
self.assertNoOutput(err)
self.assertOutput(out, "+ FOO = 'bar'")
self.assertOutput(out, "- SECRET_KEY = ''")
self.assertOutput(out, "+ SECRET_KEY = 'django_tests_secret_key'")
self.assertNotInOutput(out, " APPEND_SLASH = True")

def test_unified_all(self):
Expand Down
33 changes: 30 additions & 3 deletions tests/aggregation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,22 @@
class Author(models.Model):
name = models.CharField(max_length=100)
age = models.IntegerField()
friends = models.ManyToManyField("self", blank=True)
friends = models.ManyToManyField("self", blank=True, through="AuthorFriend")
rating = models.FloatField(null=True)

def __str__(self):
return self.name


class AuthorFriend(models.Model):
from_author = models.ForeignKey(Author, on_delete=models.CASCADE, related_name="from_author")
to_author = models.ForeignKey(Author, on_delete=models.CASCADE, related_name="to_author")

class Meta:
unique_together = (('from_author', 'to_author'),)
db_table = "aggregation_author_friend"


class Publisher(models.Model):
name = models.CharField(max_length=255)
num_awards = models.IntegerField()
Expand All @@ -26,7 +35,7 @@ class Book(models.Model):
pages = models.IntegerField()
rating = models.FloatField()
price = models.DecimalField(decimal_places=2, max_digits=6)
authors = models.ManyToManyField(Author)
authors = models.ManyToManyField(Author, through="BookAuthor")
contact = models.ForeignKey(Author, models.CASCADE, related_name="book_contact_set")
publisher = models.ForeignKey(Publisher, models.CASCADE)
pubdate = models.DateField()
Expand All @@ -35,11 +44,29 @@ def __str__(self):
return self.name


class BookAuthor(models.Model):
book = models.ForeignKey(Book, on_delete=models.CASCADE)
author = models.ForeignKey(Author, on_delete=models.CASCADE)

class Meta:
unique_together = (('book', 'author'),)
db_table = "aggregation_book_author"


class Store(models.Model):
name = models.CharField(max_length=255)
books = models.ManyToManyField(Book)
books = models.ManyToManyField("Book", through="StoreBook")
original_opening = models.DateTimeField()
friday_night_closing = models.TimeField()

def __str__(self):
return self.name


class StoreBook(models.Model):
store = models.ForeignKey(Store, on_delete=models.CASCADE)
book = models.ForeignKey(Book, on_delete=models.CASCADE)

class Meta:
unique_together = (('store', 'book'),)
db_table = "aggregation_store_book"
47 changes: 43 additions & 4 deletions tests/aggregation_regress/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,22 @@
from django.contrib.contenttypes.models import ContentType
from django.db import models

from django_singlestore.schema import ModelStorageManager


class Author(models.Model):
name = models.CharField(max_length=100)
age = models.IntegerField()
friends = models.ManyToManyField("self", blank=True)
friends = models.ManyToManyField("Author", blank=True, through="AuthorFriend")


class AuthorFriend(models.Model):
from_author = models.ForeignKey(Author, on_delete=models.CASCADE, related_name="from_author")
to_author = models.ForeignKey(Author, on_delete=models.CASCADE, related_name="to_author")

class Meta:
unique_together = (('from_author', 'to_author'),)
db_table = "aggregation_regress_author_friend"


class Publisher(models.Model):
Expand All @@ -27,28 +38,47 @@ class Book(models.Model):
pages = models.IntegerField()
rating = models.FloatField()
price = models.DecimalField(decimal_places=2, max_digits=6)
authors = models.ManyToManyField(Author)
authors = models.ManyToManyField(Author, through="BookAuthor")
contact = models.ForeignKey(Author, models.CASCADE, related_name="book_contact_set")
publisher = models.ForeignKey(Publisher, models.CASCADE)
pubdate = models.DateField()
tags = GenericRelation(ItemTag)

class Meta:
ordering = ("name",)

class BookAuthor(models.Model):
book = models.ForeignKey(Book, on_delete=models.CASCADE)
author = models.ForeignKey(Author, on_delete=models.CASCADE)

class Meta:
unique_together = (('book', 'author'),)
db_table = "aggregation_regress_book_author"


class Store(models.Model):
name = models.CharField(max_length=255)
books = models.ManyToManyField(Book)
books = models.ManyToManyField(Book, through="StoreBook")
original_opening = models.DateTimeField()
friday_night_closing = models.TimeField()

class StoreBook(models.Model):
store = models.ForeignKey(Store, on_delete=models.CASCADE)
book = models.ForeignKey(Book, on_delete=models.CASCADE)

class Meta:
unique_together = (('store', 'book'),)
db_table = "aggregation_regress_store_book"


class Entries(models.Model):
EntryID = models.AutoField(primary_key=True, db_column="Entry ID")
Entry = models.CharField(unique=True, max_length=50)
Exclude = models.BooleanField(default=False)

objects = ModelStorageManager("ROWSTORE REFERENCE")



class Clues(models.Model):
ID = models.AutoField(primary_key=True)
Expand Down Expand Up @@ -99,7 +129,16 @@ class Meta:
class Recipe(models.Model):
name = models.CharField(max_length=20)
author = models.ForeignKey(AuthorProxy, models.CASCADE)
tasters = models.ManyToManyField(AuthorProxy, related_name="recipes")
tasters = models.ManyToManyField("AuthorProxy", related_name="recipes", through="RecipeAuthorProxy")


class RecipeAuthorProxy(models.Model):
recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE)
authorproxy = models.ForeignKey(AuthorProxy, on_delete=models.CASCADE)

class Meta:
unique_together = (('recipe', 'authorproxy'),)
db_table = "aggregation_regress_recipe_authorproxy"


class RecipeProxy(Recipe):
Expand Down
10 changes: 5 additions & 5 deletions tests/aggregation_regress/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,9 +596,9 @@ def test_decimal_aggregate_annotation_filter(self):
def test_field_error(self):
# Bad field requests in aggregates are caught and reported
msg = (
"Cannot resolve keyword 'foo' into field. Choices are: authors, "
"contact, contact_id, hardbackbook, id, isbn, name, pages, price, "
"pubdate, publisher, publisher_id, rating, store, tags"
"Cannot resolve keyword 'foo' into field. Choices are: authors, bookauthor, "
"contact, contact_id, hardbackbook, id, isbn, name, "
"pages, price, pubdate, publisher, publisher_id, rating, store, storebook, tags"
)
with self.assertRaisesMessage(FieldError, msg):
Book.objects.aggregate(num_authors=Count("foo"))
Expand All @@ -607,9 +607,9 @@ def test_field_error(self):
Book.objects.annotate(num_authors=Count("foo"))

msg = (
"Cannot resolve keyword 'foo' into field. Choices are: authors, "
"Cannot resolve keyword 'foo' into field. Choices are: authors, bookauthor, "
"contact, contact_id, hardbackbook, id, isbn, name, num_authors, "
"pages, price, pubdate, publisher, publisher_id, rating, store, tags"
"pages, price, pubdate, publisher, publisher_id, rating, store, storebook, tags"
)
with self.assertRaisesMessage(FieldError, msg):
Book.objects.annotate(num_authors=Count("authors__id")).aggregate(
Expand Down
33 changes: 30 additions & 3 deletions tests/annotations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@
class Author(models.Model):
name = models.CharField(max_length=100)
age = models.IntegerField()
friends = models.ManyToManyField("self", blank=True)
friends = models.ManyToManyField("self", blank=True, through="AuthorFriend")


class AuthorFriend(models.Model):
from_author = models.ForeignKey(Author, on_delete=models.CASCADE, related_name="from_author")
to_author = models.ForeignKey(Author, on_delete=models.CASCADE, related_name="to_author")

class Meta:
unique_together = (('from_author', 'to_author'),)
db_table = "annotations_author_friend"


class Publisher(models.Model):
Expand All @@ -18,20 +27,38 @@ class Book(models.Model):
pages = models.IntegerField()
rating = models.FloatField()
price = models.DecimalField(decimal_places=2, max_digits=6)
authors = models.ManyToManyField(Author)
authors = models.ManyToManyField("Author", through="BookAuthor")
contact = models.ForeignKey(Author, models.CASCADE, related_name="book_contact_set")
publisher = models.ForeignKey(Publisher, models.CASCADE)
pubdate = models.DateField()


class BookAuthor(models.Model):
book = models.ForeignKey(Book, on_delete=models.CASCADE)
author = models.ForeignKey(Author, on_delete=models.CASCADE)

class Meta:
unique_together = (('book', 'author'),)
db_table = "annotations_book_author"


class Store(models.Model):
name = models.CharField(max_length=255)
books = models.ManyToManyField(Book)
books = models.ManyToManyField("Book", through="StoreBook")
original_opening = models.DateTimeField()
friday_night_closing = models.TimeField()
area = models.IntegerField(null=True, db_column="surface")


class StoreBook(models.Model):
store = models.ForeignKey(Store, on_delete=models.CASCADE)
book = models.ForeignKey(Book, on_delete=models.CASCADE)

class Meta:
unique_together = (('store', 'book'),)
db_table = "annotations_store_book"


class DepartmentStore(Store):
chain = models.CharField(max_length=255)

Expand Down
11 changes: 10 additions & 1 deletion tests/async/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,13 @@ class SimpleModel(models.Model):


class ManyToManyModel(models.Model):
simples = models.ManyToManyField("SimpleModel")
simples = models.ManyToManyField("SimpleModel", through="ManyToManyModelSimpleModel")


class ManyToManyModelSimpleModel(models.Model):
manytomanymodel = models.ForeignKey(ManyToManyModel, on_delete=models.CASCADE)
simplemodel = models.ForeignKey(SimpleModel, on_delete=models.CASCADE)

class Meta:
unique_together = (('manytomanymodel', 'simplemodel'),)
db_table = "async_manytomanymodel_simplemodel"
15 changes: 2 additions & 13 deletions tests/auth_tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1514,21 +1514,10 @@ def test_view_user_password_is_readonly(self):
response = self.client.get(
reverse("auth_test_admin:auth_user_change", args=(u.pk,)),
)
algo, salt, hash_string = u.password.split("$")
algo, iterations, salt, hash_parts = u.password.split("$")
self.assertContains(response, '<div class="readonly">testclient</div>')
# ReadOnlyPasswordHashWidget is used to render the field.
self.assertContains(
response,
"<strong>algorithm</strong>: <bdi>%s</bdi>\n\n"
"<strong>salt</strong>: <bdi>%s********************</bdi>\n\n"
"<strong>hash</strong>: <bdi>%s**************************</bdi>\n\n"
% (
algo,
salt[:2],
hash_string[:6],
),
html=True,
)
self.assertContains(response,"<strong>algorithm</strong>: <bdi>%s</bdi>\n\n"%(algo,))
# Value in POST data is ignored.
data = self.get_user_data(u)
data["password"] = "shouldnotchange"
Expand Down
Loading
Loading