summaryrefslogtreecommitdiff
path: root/tests/djapp
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2013-06-15 16:17:01 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2013-06-15 16:18:10 +0200
commita24e2b945166cdd32ece9bf2cab21280974143cb (patch)
treea5f0539659cb0bd012c386fe7a135fc7d159afce /tests/djapp
parentc490870c67116387f116528fc8563b8dcba37b3e (diff)
downloadfactory-boy-a24e2b945166cdd32ece9bf2cab21280974143cb.tar
factory-boy-a24e2b945166cdd32ece9bf2cab21280974143cb.tar.gz
Add factory.django.FileField (See #52)
Diffstat (limited to 'tests/djapp')
-rw-r--r--tests/djapp/models.py8
-rw-r--r--tests/djapp/settings.py10
2 files changed, 18 insertions, 0 deletions
diff --git a/tests/djapp/models.py b/tests/djapp/models.py
index c107add..52acebe 100644
--- a/tests/djapp/models.py
+++ b/tests/djapp/models.py
@@ -22,7 +22,9 @@
"""Helpers for testing django apps."""
+import os.path
+from django.conf import settings
from django.db import models
class StandardModel(models.Model):
@@ -34,3 +36,9 @@ class NonIntegerPk(models.Model):
bar = models.CharField(max_length=20, blank=True)
+WITHFILE_UPLOAD_TO = 'django'
+WITHFILE_UPLOAD_DIR = os.path.join(settings.MEDIA_ROOT, WITHFILE_UPLOAD_TO)
+
+class WithFile(models.Model):
+ afile = models.FileField(upload_to=WITHFILE_UPLOAD_TO)
+
diff --git a/tests/djapp/settings.py b/tests/djapp/settings.py
index 787d3f3..c1b79b0 100644
--- a/tests/djapp/settings.py
+++ b/tests/djapp/settings.py
@@ -20,6 +20,16 @@
# THE SOFTWARE.
"""Settings for factory_boy/Django tests."""
+import os
+
+FACTORY_ROOT = os.path.join(
+ os.path.abspath(os.path.dirname(__file__)), # /path/to/fboy/tests/djapp/
+ os.pardir, # /path/to/fboy/tests/
+ os.pardir, # /path/to/fboy
+)
+
+MEDIA_ROOT = os.path.join(FACTORY_ROOT, 'tmp_test')
+
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',