]> git.parisson.com Git - telemeta.git/commitdiff
Test: add first minimal test for instruments model
authorThomas Fillon <thomas@parisson.com>
Fri, 21 Nov 2014 16:40:15 +0000 (17:40 +0100)
committerThomas Fillon <thomas@parisson.com>
Fri, 21 Nov 2014 16:40:15 +0000 (17:40 +0100)
setup.py
telemeta/tests/instrument_factories.py [new file with mode: 0644]
telemeta/tests/settings_sqlite.py
telemeta/tests/test_models_instrument.py [new file with mode: 0644]

index 72846d13ded68031a1abebf5ccf562f57065cd01..e9e56a8ec4c3254e3088b53ffa002c253e0de754 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -67,7 +67,7 @@ setup(
         'pyyaml',
         'python-ebml',
     ],
-  tests_require=['pytest-django', 'pytest-cov'],
+  tests_require=['pytest-django', 'pytest-cov', 'factory-boy'],
   # Provide a test command through django-setuptest
   cmdclass={'test': PyTest},
   dependency_links = ['https://github.com/yomguy/django-json-rpc/tarball/0.6.2#egg=django-json-rpc-0.6.2'],
diff --git a/telemeta/tests/instrument_factories.py b/telemeta/tests/instrument_factories.py
new file mode 100644 (file)
index 0000000..54214cd
--- /dev/null
@@ -0,0 +1,15 @@
+# -*- coding: utf-8 -*-
+"""
+Factories for the telemeta.models.instrument
+
+"""
+import factory
+
+from telemeta.models.instrument import Instrument
+
+
+class InstrumentFactory(factory.django.DjangoModelFactory):
+    class Meta:
+        model = Instrument
+
+    name = factory.Sequence(lambda n: 'name{0}'.format(n))
index eef9ebdbdb9d0c1643907c6a84a59f96d4868d03..ef5262b3c28e16f320002980fb8fe270958d7c1d 100644 (file)
@@ -1,4 +1,4 @@
-from telemeta.settings_base import SECRET_KEY
+from telemeta.settings_base import SECRET_KEY, INSTALLED_APPS
 
 
 DATABASES = {
diff --git a/telemeta/tests/test_models_instrument.py b/telemeta/tests/test_models_instrument.py
new file mode 100644 (file)
index 0000000..bc00512
--- /dev/null
@@ -0,0 +1,9 @@
+# -*- coding: utf-8 -*-
+
+from . instrument_factories import InstrumentFactory
+import pytest
+
+
+@pytest.mark.django_db
+def test_Instrument():
+    instrument = InstrumentFactory.build()