Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
timgraham committed Nov 19, 2024
1 parent 4669613 commit 3e6411e
Show file tree
Hide file tree
Showing 6 changed files with 394 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"queries",
"queries_",
"queryset_pickle",
"raw_query",
"raw_query_",
"redirects_tests",
"reserved_names",
"reverse_lookup",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Checkout Django
uses: actions/checkout@v4
with:
repository: 'aclark4life/django'
repository: 'mongodb-forks/django'
ref: 'mongodb-5.0.x'
path: 'django_repo'
persist-credentials: false
Expand Down
1 change: 1 addition & 0 deletions django_mongodb/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ def django_test_expected_failures(self):
"multiple_database.tests.QueryTestCase.test_raw",
"prefetch_related.tests.RawQuerySetTests",
"queries.tests.Queries1Tests.test_order_by_rawsql",
"raw_query.tests.RawQueryTests",
"schema.test_logging.SchemaLoggerTests.test_extra_args",
"schema.tests.SchemaTests.test_remove_constraints_capital_letters",
"timezones.tests.LegacyDatabaseTests.test_cursor_execute_accepts_naive_datetime",
Expand Down
Empty file added tests/raw_query_/__init__.py
Empty file.
60 changes: 60 additions & 0 deletions tests/raw_query_/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from django.db import models

from django_mongodb.fields import ObjectIdAutoField
from django_mongodb.managers import MongoManager


class Author(models.Model):
first_name = models.CharField(max_length=255)
last_name = models.CharField(max_length=255)
dob = models.DateField()

objects = MongoManager()

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Protect against annotations being passed to __init__ --
# this'll make the test suite get angry if annotations aren't
# treated differently than fields.
for k in kwargs:
assert k in [f.attname for f in self._meta.fields], (
"Author.__init__ got an unexpected parameter: %s" % k
)


class Book(models.Model):
title = models.CharField(max_length=255)
author = models.ForeignKey(Author, models.CASCADE)
paperback = models.BooleanField(default=False)
opening_line = models.TextField()

objects = MongoManager()


class BookFkAsPk(models.Model):
book = models.ForeignKey(Book, models.CASCADE, primary_key=True, db_column="not_the_default")

objects = MongoManager()


class Coffee(models.Model):
brand = models.CharField(max_length=255, db_column="name")
price = models.DecimalField(max_digits=10, decimal_places=2, default=0)

objects = MongoManager()


class MixedCaseIDColumn(models.Model):
id = ObjectIdAutoField(primary_key=True, db_column="MiXeD_CaSe_Id")

objects = MongoManager()


class Reviewer(models.Model):
reviewed = models.ManyToManyField(Book)

objects = MongoManager()


class FriendlyAuthor(Author):
pass
Loading

0 comments on commit 3e6411e

Please sign in to comment.