Skip to content

Commit

Permalink
Fix issue when configuring app and db separately
Browse files Browse the repository at this point in the history
Fixes GH Issue #5
  • Loading branch information
diddi- committed Feb 29, 2020
1 parent 1dbd6dd commit 8fb9fe5
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

# Change Log
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

## 1.1.1 - 2020-02-29

### Added
- None

### Changed
- None

### Fixed

- Issue #5:
Fix issue when configuring `app` and `db` separately
2 changes: 1 addition & 1 deletion flask_seeder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ def init_app(self, app, db=None):
if not hasattr(app, 'extensions'):
app.extensions = {}

app.extensions['flask_seeder'] = SeedConfig(db)
app.extensions['flask_seeder'] = SeedConfig(self.db)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="Flask-Seeder",
version="1.1.0",
version="1.1.1",
url="https://github.com/diddi-/flask-seeder",
author="Diddi Oskarsson",
author_email="[email protected]",
Expand Down
18 changes: 18 additions & 0 deletions tests/test_flask_seeder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from unittest import TestCase
from unittest.mock import MagicMock
from flask_seeder import FlaskSeeder

class TestFlaskSeeder(TestCase):

def test_init_app_without_db(self):
""" FlaskSeeder should use db object when passed via constructor.
"""
db = MagicMock()
app = MagicMock()
ext = {}
app.extensions.__setitem__.side_effect = ext.__setitem__
seeder = FlaskSeeder(db=db)

seeder.init_app(app)

self.assertEqual(ext["flask_seeder"].db, db)

0 comments on commit 8fb9fe5

Please sign in to comment.