diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..8cec5c5 --- /dev/null +++ b/CHANGELOG.md @@ -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 diff --git a/flask_seeder/__init__.py b/flask_seeder/__init__.py index 2727985..e6567f8 100755 --- a/flask_seeder/__init__.py +++ b/flask_seeder/__init__.py @@ -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) diff --git a/setup.py b/setup.py index 8564b1e..44ca497 100755 --- a/setup.py +++ b/setup.py @@ -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="diddi@diddi.se", diff --git a/tests/test_flask_seeder.py b/tests/test_flask_seeder.py new file mode 100644 index 0000000..fc6185d --- /dev/null +++ b/tests/test_flask_seeder.py @@ -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)