forked from croach/Flask-Fixtures
-
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
3 changed files
with
56 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from __future__ import absolute_import | ||
|
||
import os | ||
import unittest | ||
|
||
from myapp import app | ||
from myapp.models import db, Book, Author | ||
|
||
from flask_fixtures import load_fixtures_from_file, push_ctx, pop_ctx | ||
|
||
# Configure the app with the testing configuration | ||
app.config.from_object('myapp.config.TestConfig') | ||
fixtures_dirs = [os.path.join(app.root_path, 'fixtures')] | ||
|
||
class TestLoadFixturesFromFile(unittest.TestCase): | ||
def setUp(self): | ||
push_ctx(app) | ||
# Setup the database | ||
db.create_all() | ||
# Rollback any lingering transactions | ||
db.session.rollback() | ||
|
||
def tearDown(self): | ||
db.session.expunge_all() | ||
db.drop_all() | ||
pop_ctx() | ||
|
||
def test_load_fixtures_file_json(self): | ||
load_fixtures_from_file(db, 'authors.json', fixtures_dirs) | ||
assert Author.query.count() == 1 | ||
assert Book.query.count() == 3 | ||
|
||
def test_load_fixtures_file_json_abs(self): | ||
load_fixtures_from_file(db, 'myapp/fixtures/authors.json') | ||
assert Author.query.count() == 1 | ||
assert Book.query.count() == 3 | ||
|
||
def test_load_fixtures_file_yaml(self): | ||
load_fixtures_from_file(db, 'authors.yaml', fixtures_dirs) | ||
assert Author.query.count() == 1 | ||
assert Book.query.count() == 3 |
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 |
---|---|---|
|
@@ -15,3 +15,4 @@ deps = | |
discover | ||
nose | ||
pytest | ||
pyyaml |