tests: add option to update tables during tests (#38067)
If table contents change, we can measure the change and eventually accept by copying new_table.json to tables.json. To activate it, use --bijoe-store-table .
This commit is contained in:
parent
65a78b93dc
commit
9cc619ee0d
|
@ -18,6 +18,12 @@ from django.contrib.auth.models import User
|
|||
from django.core.management import call_command
|
||||
|
||||
|
||||
def pytest_addoption(parser):
|
||||
parser.addoption(
|
||||
'--bijoe-store-table', action='store_true', default=False, help='Store tables value in new_tables.json',
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def app(settings, request):
|
||||
settings.TEMPLATE_DEBUG = True
|
||||
|
|
|
@ -35,13 +35,24 @@ def freezetime(freezer):
|
|||
freezer.move_to('2018-12-07 16:53:00')
|
||||
|
||||
|
||||
def test_simple(schema2, app, admin, visualization):
|
||||
def test_simple(request, 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)
|
||||
if request.config.getoption('--bijoe-store-table'):
|
||||
d = {}
|
||||
new_table_path = 'tests/fixtures/schema2/new_tables.json'
|
||||
if os.path.exists(new_table_path):
|
||||
with open(new_table_path) as fd:
|
||||
d = json.load(fd)
|
||||
if 'tables' in d:
|
||||
d = d['tables']
|
||||
d[visualization] = table
|
||||
with open(new_table_path, 'w') as fd:
|
||||
json.dump(d, fd, indent=4, sort_keys=True, separators=(',', ': '))
|
||||
assert_equal_tables(
|
||||
schema2['tables'][visualization],
|
||||
table)
|
||||
|
|
Loading…
Reference in New Issue