-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from danielrichman/master
Move spacenearus filter to habitat-transition
- Loading branch information
Showing
3 changed files
with
75 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
spacenearus: | ||
filters: | ||
spacenear: habitat_transition.spacenearus.spacenear_filter |
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,57 @@ | ||
# Copyright 2012 (C) Adam Greig | ||
# | ||
# This file is part of habitat. | ||
# | ||
# habitat is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# habitat is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with habitat. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
""" | ||
Tests SpaceNear document functions | ||
""" | ||
|
||
from . import spacenearus | ||
|
||
from copy import deepcopy | ||
|
||
doc = { | ||
"type": "payload_telemetry", | ||
"data": { | ||
"_parsed": "test test" | ||
} | ||
} | ||
|
||
def test_spacenear_filter(): | ||
fil = spacenearus.spacenear_filter | ||
|
||
wrongtype = deepcopy(doc) | ||
wrongtype["type"] = "flight" | ||
assert not fil(wrongtype, {}) | ||
|
||
listener = deepcopy(doc) | ||
listener["type"] = "listener_telemetry" | ||
assert fil(listener, {}) | ||
|
||
parsed = deepcopy(doc) | ||
assert fil(parsed, {}) | ||
|
||
nodata = deepcopy(doc) | ||
del nodata['data'] | ||
assert not fil(nodata, {}) | ||
|
||
notparsed = deepcopy(doc) | ||
del notparsed['data']['_parsed'] | ||
assert not fil(notparsed, {}) | ||
|
||
def test_issue_241(): | ||
# this should not produce an exception | ||
spacenearus.spacenear_filter({"_deleted": True}, {}) |