forked from move-coop/parsons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
41 lines (31 loc) · 1.07 KB
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from parsons.etl.table import Table
import os
import pytest
"""
Use this as a marker before any tests that hit live services. That way they'll only run
if you set the "LIVE_TEST" env var.
Example usage:
@mark_live_test
def test_something():
service = SomeService()
...
"""
mark_live_test = pytest.mark.skipif(
not os.environ.get('LIVE_TEST'), reason='Skipping because not running live test')
# Tests whether a table has the expected structure
def validate_list(expected_keys, table):
if set(expected_keys) != set(table.columns):
raise KeyError('Not all expected keys found.')
return True
def assert_matching_tables(table1, table2, ignore_headers=False):
if ignore_headers:
data1 = table1.data
data2 = table2.data
else:
data1 = table1
data2 = table2
if isinstance(data1, Table) and isinstance(data2, Table):
assert data1.num_rows == data2.num_rows
for r1, r2 in zip(data1, data2):
# Cast both rows to lists, in case they are different types of collections
assert list(r1) == list(r2)