forked from doableware/djongo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
195 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
tests/djongo_tests/project/dummy/tests/test_embedded_models.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from dummy.models.array_models import ArrayEntry, ArrayAuthor | ||
from dummy.models.basic_models import Blog, Entry, Author | ||
from dummy.models.embedded_models import EmbeddedBlog, EmbeddedEntry | ||
from dummy.models.reference_models import ReferenceEntry, ReferenceAuthor | ||
|
@@ -30,7 +31,7 @@ def test_create(self): | |
self.assertEqual([a1], list(e1.authors.all())) | ||
self.assertEqual([e1], list(a1.referenceentry_set.all())) | ||
|
||
e2.authors.add(a1,a2) | ||
e2.authors.add(a1, a2) | ||
self.assertEqual(e2.authors_id, {a1.pk, a2.pk}) | ||
self.assertEqual([a1, a2], list(e2.authors.all())) | ||
self.assertEqual([e1, e2], list(a1.referenceentry_set.all())) | ||
|
@@ -51,18 +52,54 @@ def test_create(self): | |
self.assertEqual([a1], list(e2.authors.all())) | ||
self.assertEqual([a1], list(e1.authors.all())) | ||
|
||
|
||
class TestArray(TestCase): | ||
def test_create1(self): | ||
e = ArrayEntry.objects.create( | ||
headline='h1', | ||
authors=[ArrayAuthor( | ||
name='n1', | ||
email='[email protected]' | ||
)] | ||
) | ||
g = ArrayEntry.objects.get(headline='h1') | ||
self.assertEqual(e, g) | ||
g.authors.append( | ||
ArrayAuthor( | ||
name='n2', | ||
email='[email protected]' | ||
) | ||
) | ||
g.save() | ||
g = ArrayEntry.objects.get( | ||
authors={'1.name': 'n2'} | ||
) | ||
self.assertEqual(e,g) | ||
self.assertNotEqual(e.authors, g.authors) | ||
|
||
|
||
class TestEmbedded(TestCase): | ||
|
||
def test_create(self): | ||
e = EmbeddedEntry.objects.create( | ||
headline='h1', | ||
blog=EmbeddedBlog(name='b1', tagline='t1') | ||
blog=EmbeddedBlog( | ||
name='b1', | ||
tagline='t1' | ||
) | ||
) | ||
g = EmbeddedEntry.objects.get(headline='h1') | ||
self.assertEqual(e, g) | ||
|
||
g = EmbeddedEntry.objects.get(blog={'name': 'b1'}) | ||
self.assertEqual(e, g) | ||
self.assertEqual(g.blog.tagline, 't1') | ||
g.blog.tagline = 't2' | ||
g.save() | ||
g = EmbeddedEntry.objects.get(blog={'name': 'b1'}) | ||
self.assertEqual(e, g) | ||
self.assertEqual(g.blog.tagline, 't2') | ||
self.assertNotEqual(e.blog.tagline, g.blog.tagline) | ||
|
||
# def test_join(self): | ||
# eqs = EmbeddedEntry.objects.filter(blog__name='b1').values('id') | ||
|
@@ -116,7 +153,7 @@ def test_create(self): | |
self.assertEqual([a1], list(e1.authors.all())) | ||
self.assertEqual([e1], list(a1.entry_set.all())) | ||
|
||
e2.authors.add(a1,a2) | ||
e2.authors.add(a1, a2) | ||
self.assertEqual([a1, a2], list(e2.authors.all())) | ||
self.assertEqual([e1, e2], list(a1.entry_set.all())) | ||
self.assertEqual([e2], list(a2.entry_set.all())) | ||
|
@@ -162,7 +199,3 @@ def test_join(self): | |
bqs = Blog.objects.filter(id__in=eqs).values('name') | ||
self.assertEquals(list(bqs), [{'name': 'b1'}, {'name': 'b2'}]) | ||
|
||
|
||
class TestArray(TestCase): | ||
pass | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
tests/djongo_tests/project/project/settings_precheckin.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
""" | ||
Django settings for dummy_app project. | ||
Generated by 'django-admin startproject' using Django 1.11.2. | ||
For more information on this file, see | ||
https://docs.djangoproject.com/en/1.11/topics/settings/ | ||
For the full list of settings and their values, see | ||
https://docs.djangoproject.com/en/1.11/ref/settings/ | ||
""" | ||
|
||
import os | ||
|
||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) | ||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||
|
||
|
||
# Quick-start development settings - unsuitable for production | ||
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ | ||
|
||
# SECURITY WARNING: keep the secret key used in production secret! | ||
SECRET_KEY = '5s(0&1x3(963q!xdyt1=$^(5om4(_=_39ys6=bnp7n-h8%7z+(' | ||
|
||
# SECURITY WARNING: don't run with debug turned on in production! | ||
DEBUG = True | ||
|
||
ALLOWED_HOSTS = ['localhost','127.0.0.1'] | ||
|
||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'djongo', | ||
'NAME': 'djongo-test', | ||
'ENFORCE_SCHEMA': True | ||
|
||
}, | ||
} | ||
# Application definition | ||
|
||
INSTALLED_APPS = [ | ||
'dummy.apps.DummyConfig', | ||
'django.contrib.admin', | ||
'django.contrib.auth', | ||
'django.contrib.contenttypes', | ||
'django.contrib.sessions', | ||
'django.contrib.messages', | ||
'django.contrib.staticfiles', | ||
'django_extensions', | ||
] | ||
|
||
|
||
MIDDLEWARE = [ | ||
'django.middleware.security.SecurityMiddleware', | ||
'django.contrib.sessions.middleware.SessionMiddleware', | ||
'django.middleware.common.CommonMiddleware', | ||
'django.middleware.csrf.CsrfViewMiddleware', | ||
'django.contrib.auth.middleware.AuthenticationMiddleware', | ||
'django.contrib.messages.middleware.MessageMiddleware', | ||
'django.middleware.clickjacking.XFrameOptionsMiddleware', | ||
] | ||
|
||
ROOT_URLCONF = 'project.urls' | ||
|
||
TEMPLATES = [ | ||
{ | ||
'BACKEND': 'django.template.backends.django.DjangoTemplates', | ||
'DIRS': [], | ||
'APP_DIRS': True, | ||
'OPTIONS': { | ||
'context_processors': [ | ||
'django.template.context_processors.debug', | ||
'django.template.context_processors.request', | ||
'django.contrib.auth.context_processors.auth', | ||
'django.contrib.messages.context_processors.messages', | ||
], | ||
}, | ||
}, | ||
] | ||
|
||
WSGI_APPLICATION = 'project.wsgi.application' | ||
|
||
|
||
|
||
# Password validation | ||
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators | ||
|
||
AUTH_PASSWORD_VALIDATORS = [ | ||
{ | ||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', | ||
}, | ||
{ | ||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', | ||
}, | ||
{ | ||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', | ||
}, | ||
{ | ||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', | ||
}, | ||
] | ||
|
||
|
||
# Internationalization | ||
# https://docs.djangoproject.com/en/1.11/topics/i18n/ | ||
|
||
LANGUAGE_CODE = 'en-us' | ||
|
||
TIME_ZONE = 'UTC' | ||
|
||
USE_I18N = True | ||
|
||
USE_L10N = True | ||
|
||
USE_TZ = True | ||
|
||
|
||
# Static files (CSS, JavaScript, Images) | ||
# https://docs.djangoproject.com/en/1.11/howto/static-files/ | ||
|
||
STATIC_URL = '/static/' | ||
|
||
STATIC_ROOT = os.path.join(BASE_DIR, 'static') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters