-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into absolute-imports
- Loading branch information
Showing
4 changed files
with
53 additions
and
3 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,20 @@ | ||
from blinker import signal | ||
|
||
|
||
project_changed = signal('bw2data.project_changed', doc=""" | ||
Emitted when project changed, after redirecting any SQLite database references. | ||
Expected inputs: | ||
* `bw2data.projects.ProjectDataset` instance | ||
No expected return value. | ||
""") | ||
|
||
project_created = signal('bw2data.project_created', doc=""" | ||
Emitted when project created, but before switching to that project, and before any filesystem ops. | ||
Expected inputs: | ||
* `bw2data.projects.ProjectDataset` instance | ||
No expected return value. | ||
""") |
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,28 @@ | ||
from bw2data.project import ProjectDataset, projects | ||
from bw2data.tests import bw2test | ||
from blinker import signal | ||
|
||
|
||
class SignalCatcher: | ||
def __call__(self, arg): | ||
self.arg = arg | ||
|
||
|
||
@bw2test | ||
def test_project_changed_signal(): | ||
subscriber = SignalCatcher() | ||
signal('bw2data.project_changed').connect(subscriber) | ||
projects.set_current("foo") | ||
|
||
assert isinstance(subscriber.arg, ProjectDataset) | ||
assert subscriber.arg.name == 'foo' | ||
|
||
|
||
@bw2test | ||
def test_project_created_signal(): | ||
subscriber = SignalCatcher() | ||
signal('bw2data.project_created').connect(subscriber) | ||
projects.set_current("foo") | ||
|
||
assert isinstance(subscriber.arg, ProjectDataset) | ||
assert subscriber.arg.name == 'foo' |