-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Function for mapping column names to the tables that contain them.
- Loading branch information
Showing
2 changed files
with
68 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
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,35 @@ | ||
import pytest | ||
|
||
from .. import misc | ||
|
||
|
||
class _FakeTable(object): | ||
def __init__(self, name, columns): | ||
self.name = name | ||
self.columns = columns | ||
|
||
|
||
@pytest.fixture | ||
def fta(): | ||
return _FakeTable('a', ['aa', 'ab', 'ac']) | ||
|
||
|
||
@pytest.fixture | ||
def ftb(): | ||
return _FakeTable('b', ['bx', 'by', 'bz']) | ||
|
||
|
||
def test_column_map_raises(fta, ftb): | ||
with pytest.raises(RuntimeError): | ||
misc.column_map([fta, ftb], ['aa', 'by', 'bz', 'cw']) | ||
|
||
|
||
def test_column_map_none(fta, ftb): | ||
assert misc.column_map([fta, ftb], None) == {'a': None, 'b': None} | ||
|
||
|
||
def test_column_map(fta, ftb): | ||
assert misc.column_map([fta, ftb], ['aa', 'by', 'bz']) == \ | ||
{'a': ['aa'], 'b': ['by', 'bz']} | ||
assert misc.column_map([fta, ftb], ['by', 'bz']) == \ | ||
{'a': [], 'b': ['by', 'bz']} |