48 lines
1.2 KiB
Python
48 lines
1.2 KiB
Python
import json
|
|
import os
|
|
import re
|
|
|
|
import pytest
|
|
from tabulate import tabulate
|
|
|
|
from utils import login, get_table
|
|
|
|
|
|
def pytest_generate_tests(metafunc):
|
|
if hasattr(metafunc, 'function'):
|
|
fcode = metafunc.function.func_code
|
|
if 'visualization' in fcode.co_varnames[:fcode.co_argcount]:
|
|
tables = json.load(
|
|
open(
|
|
os.path.join(
|
|
os.path.dirname(__file__),
|
|
'fixtures',
|
|
'schema2',
|
|
'tables.json')))
|
|
metafunc.parametrize(['visualization'], [[x] for x in tables])
|
|
|
|
|
|
def assert_equal_tables(table1, table2):
|
|
t1 = tabulate(table1)
|
|
t2 = tabulate(table2)
|
|
t1 = re.sub(' +', ' ', t1)
|
|
t2 = re.sub(' +', ' ', t2)
|
|
assert t1 == t2
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def freezetime(freezer):
|
|
freezer.move_to('2018-12-07 16:53:00')
|
|
|
|
|
|
def test_simple(schema2, app, admin, visualization):
|
|
login(app, admin)
|
|
response = app.get('/')
|
|
|
|
visualization_page = response.click(lambda x: x == visualization)
|
|
assert 'big-msg-info' not in visualization_page
|
|
table = get_table(visualization_page)
|
|
assert_equal_tables(
|
|
schema2['tables'][visualization],
|
|
table)
|