Improve testing setup for UI.

This commit is contained in:
Dorian 2017-04-10 08:15:01 -04:00
parent 2f223326c6
commit 0cc2fbb21c
3 changed files with 37 additions and 14 deletions

View File

@ -1,3 +1,10 @@
.git .git
.cache
node_modules node_modules
.circleci .circleci
Makefile
docker-compose.yml
Dockerfile
.docker-repository.yml
.gitignore
scripts

View File

@ -31,7 +31,7 @@ def prepare_assets(ctx):
@inv.task @inv.task
def wait(ctx, timeout=10): def wait(ctx, timeout=10):
inv.run(f'dockerize -wait http://rookeries:5000 -timeout {timeout}s') inv.run(f'dockerize -wait http://rookeries:5000/status -timeout {timeout}s')
@inv.task(prepare_assets) @inv.task(prepare_assets)

View File

@ -8,7 +8,9 @@ Unit tests for testing serving of page content.
import pytest import pytest
import sqlalchemy import sqlalchemy
from rookeries.pages import models from rookeries.pages import models as page_models
from rookeries.sites import models as site_models
from tests import utils
TEST_PAGE_TITLE = 'License' TEST_PAGE_TITLE = 'License'
TEST_PAGE_SLUG = 'license' TEST_PAGE_SLUG = 'license'
@ -28,30 +30,44 @@ def splinter_driver_kwargs():
# TODO: Change these tests to be bdd style functional tests. # TODO: Change these tests to be bdd style functional tests.
@pytest.fixture(scope='module')
def test_site(db_engine):
site = utils.generate_test_site()
utils.save_test_site_in_db(db_engine, site)
return site
@pytest.fixture(scope='module') @pytest.fixture(scope='module')
def test_page(db_engine): def test_page(db_engine, test_site):
session = sqlalchemy.orm.sessionmaker(bind=db_engine, autocommit=True)() session = sqlalchemy.orm.sessionmaker(bind=db_engine, autocommit=True)()
session.begin() session.begin()
test_page_ = session.query(models.Page).filter_by(slug=TEST_PAGE_SLUG).first()
test_page_site = session.query(site_models.Site).filter_by(name=test_site.site_name).first()
if not test_page_site:
raise ValueError(f'Expected "{test_site.site_name}" to be present before test.')
test_page_ = session.query(page_models.Page).filter(
(page_models.Page.site == test_page_site) & (page_models.Page.slug == TEST_PAGE_SLUG)
).first()
if not test_page_: if not test_page_:
test_page_ = models.Page(slug=TEST_PAGE_SLUG, title=TEST_PAGE_TITLE, content=TEST_PAGE_CONTENT) test_page_ = page_models.Page(slug=TEST_PAGE_SLUG, title=TEST_PAGE_TITLE, content=TEST_PAGE_CONTENT)
test_page_.site = test_page_site
session.add(test_page_) session.add(test_page_)
test_page_ = session.query(models.Page).filter_by(slug=TEST_PAGE_SLUG).first()
test_page_ = session.query(page_models.Page).filter(
(page_models.Page.site == test_page_site) & (page_models.Page.slug == TEST_PAGE_SLUG)
).first()
test_page_json = test_page_.to_json() test_page_json = test_page_.to_json()
session.commit() session.commit()
session.close() session.close()
return test_page_json return test_page_json
def test_basic_site_setup_on_test_site(browser, api_base_uri, test_page): @pytest.skip.mark('FIXME once page setup figured out')
browser.visit(f'{api_base_uri}') def test_basic_page_setup_on_test_site(browser, api_base_uri, test_page, test_site):
assert browser.title == 'Rookeries' browser.visit(f'{api_base_uri}/proxy/{test_site.site_name}/{test_page["slug"]}')
@pytest.mark.skip('Test needs redo based on new page to site setup.')
def test_basic_page_setup_on_test_site(browser, api_base_uri, test_page):
browser.visit(f'{api_base_uri}/{TEST_PAGE_SLUG}')
assert browser.title == 'Rookeries' assert browser.title == 'Rookeries'
page_title = browser.find_by_css('h1')[2] page_title = browser.find_by_css('h1')[2]