Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lettuce
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
lettuce
Commits
b3098d34
Commit
b3098d34
authored
Oct 30, 2013
by
Danielle Madeley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Django steps documentation
parent
44244cff
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
116 additions
and
0 deletions
+116
-0
docs/contents.rst
+1
-0
docs/index.rst
+1
-0
docs/reference/django.rst
+114
-0
No files found.
docs/contents.rst
View file @
b3098d34
...
@@ -20,6 +20,7 @@ Lettuce documentation contents
...
@@ -20,6 +20,7 @@ Lettuce documentation contents
reference/features
reference/features
reference/terrain
reference/terrain
reference/languages
reference/languages
reference/django
recipes/nose
recipes/nose
recipes/django-lxml
recipes/django-lxml
dev/index
dev/index
...
...
docs/index.rst
View file @
b3098d34
...
@@ -133,6 +133,7 @@ furthermore
...
@@ -133,6 +133,7 @@ furthermore
* :ref:`features, scenarios and steps <reference-features>`, diving into lettuce's core
* :ref:`features, scenarios and steps <reference-features>`, diving into lettuce's core
* :ref:`terrain, world and hooks <reference-terrain>`, stuff about setting up a environment for lettuce
* :ref:`terrain, world and hooks <reference-terrain>`, stuff about setting up a environment for lettuce
* :ref:`language support <reference-languages>`
* :ref:`language support <reference-languages>`
* :ref:`django steps <reference-django>`
#######
#######
recipes
recipes
...
...
docs/reference/django.rst
0 → 100644
View file @
b3098d34
.. _reference-django:
=====================
Built-in Django Steps
=====================
Lettuce features a number of built-in steps for Django to simplify the
creation of fixtures.
*********************
creating fixture data
*********************
Lettuce can automatically introspect your available Django models to create
fixture data, e.g.
.. highlight:: ruby
::
Background:
Given I have options in the database:
| name | value |
| Lettuce | Rocks |
This will find a model whose verbose name is *options*. It will then create
objects for that model with the parameters specified in the table (i.e.
``name=Lettuce``, ``value=Rocks``).
You can also specify relational information. Assuming a model ``Profile`` with
foreign key *user* and field *avatar*:
.. highlight:: ruby
::
Background:
Given user with username "harvey" has profile in the database:
| avatar |
| cat.jpg |
Most common data can be parsed, i.e. true/false, digits, strings and dates in
the form ``2013-10-30``.
registering your own model creators
-----------------------------------
For more complex models that have to process or parse data you can write your
own creating steps using the ``creates_models`` decorator.
.. highlight:: python
::
from lettuce.django.steps.models import (creates_models,
reset_sequence,
hashes_data)
@creates_models(Note)
def create_note(step):
data = hashes_data(step)
for row in data:
# convert the author into a user object
row['author'] = get_user(row['author'])
Note.objects.create(**row)
reset_sequence(Note)
**************
testing models
**************
Two steps exist to test models.
.. highlight:: ruby
::
Then features should be present in the database:
| name | value |
| Lettuce | Rocks |
And there should be 1 feature in the database
You can also test non-database model attributes by prefixing an ``@`` to the
attribute name. Non-database attributes are tested after the records are
selected from the database.
.. highlight:: ruby
::
Then features should be present in the database:
| name | value | @language |
| Lettuce | Rocks | Python |
registering your own model testers
-----------------------------------
For more complex tests that have to process or parse data you can write your
own creating steps using the ``checks_existence`` decorator.
*********************
settings.py variables
*********************
``LETTUCE_APPS`` -- apps to test by default
``LETTUCE_USE_TEST_DATABASE`` -- use a test database instead of the live
database. Equivalent of ``-T`` flag.
other considered variables
--------------------------
``SOUTH_TESTS_MIGRATE`` -- apply a south migration to the test database
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment