def test_create_entry(dbtransaction): """Assert entry was entered into database.""" new_entry = Entry(title="Entry1", text="Hey, this works. Awesome.") assert new_entry.id is None DBSession.add(new_entry) DBSession.flush() assert new_entry.id is not None
def test_edit_route(dbtransaction, app): """Test if permissions block anonymous users.""" new_model = Entry(title="new stuff", text="stuff goes here") DBSession.add(new_model) DBSession.flush() response = app.get('/edit/{}'.format(new_model.id), status=403) assert response.status_code == 403
def loaded_db(dbtransaction): """Instantiate a temporary database. Return one entry.""" from learning_journal.models import Entry, DBSession new_model = Entry(title="scotist", text='haecceitas') DBSession.add(new_model) DBSession.flush() return new_model
def test_create_mymodel_entry(dbtransaction, dummy_request): """Test creation of model.""" new_model = Entry(title="new stuff", text="stuff goes here") assert new_model.id is None DBSession.add(new_model) DBSession.flush() assert new_model.id is not None
def test_edit_route(dbtransaction, app): """Test if permissions block anonymous users.""" new_model = Entry(title="scotist", text="haecceitas") DBSession.add(new_model) DBSession.flush() with pytest.raises(webtestapp.AppError): app.get('/edit/{}'.format(new_model.id))
def test_create_entry(sqlengine): """Assert entry was entered into database.""" new_entry = Entry(title="Entry1", text="Hey, this works. Awesome.") assert new_entry.id is None DBSession.add(new_entry) DBSession.flush() assert new_entry.id is not None
def test_create_entry(dbtransaction): """Test for a change of state of the model.""" new_model = Entry(title='something', text='something else') assert new_model.id is None DBSession.add(new_model) DBSession.flush() assert new_model.id is not None
def test_create_entry(dbtransaction): """Test for a change of state of the model.""" new_model = Entry(title="jill", text='jello') assert new_model.id is None DBSession.add(new_model) DBSession.flush() assert new_model.id is not None
def loaded_db_item(dbtransaction): """Instantiate a temporary database. Return one entry.""" from learning_journal.models import Entry, DBSession new_model = Entry(title="jill", text='jello') DBSession.add(new_model) DBSession.flush() return new_model
def test_models(dbtransaction): new_post = Post(title="\u1555( \u141b )\u1557", text='( \u0361\xb0 \u035c\u0296 \u0361\xb0)') assert new_post.id is None assert new_post.created is None DBSession.add(new_post) DBSession.flush() assert new_post.id is not None assert new_post.created is not None
def test_list_view(dbtransaction, dummy_request): """Test list view function.""" from learning_journal.views import list_view new_model = Entry(title="scotist", text="haecceitas") DBSession.add(new_model) DBSession.flush() response_dict = list_view(dummy_request) assert response_dict['content'].one().title == new_model.title
def test_authenticated_edit_route(app): """Test if permissions allow admin.""" app.post('/login', AUTH_DATA) app.get('/create') new_model = Entry(title="new stuff", text="stuff goes here") DBSession.add(new_model) DBSession.flush() edit = app.get('/edit/1') assert edit.status_code == 200
def test_edit_my_model_entry(dbtransaction, dummy_request): """Test editing of model.""" new_model = Entry(title="Norton", text="waffles") DBSession.add(new_model) DBSession.flush() edit = "python3 is better than python2.7" new_model.text = edit DBSession.flush() assert new_model.text == edit
def test_edit_my_model_entry(dbtransaction, dummy_request): """Test editing of model.""" new_model = Entry(title="new stuff", text="stuff goes here") DBSession.add(new_model) DBSession.flush() edit = "yet more stuff for the place where stuff goes" new_model.text = edit DBSession.flush() assert new_model.text == edit
def test_detail_view(dbtransaction, dummy_request): """Test detail view function.""" from learning_journal.views import detail_view new_model = Entry(title="scotist", text="haecceitas") DBSession.add(new_model) DBSession.flush() dummy_request.matchdict = {'entry_id': new_model.id} response_dict = detail_view(dummy_request) assert response_dict['entry'].markdown_text == '<p>haecceitas</p>'
def test_create_mymodel_entry(dbtransaction, dummy_request): """Test creation of model.""" new_model = Entry(title="Norton", text="waffles") assert new_model.id is None DBSession.add(new_model) DBSession.flush() assert new_model.id is not None assert new_model.text == 'waffles' assert new_model.title == 'Norton' assert new_model.created is not None
def new_entry(request): new_entry = Entry(title='something', text='whatever') DBSession.add(new_entry) DBSession.flush() def teardown(): DBSession.query(Entry).filter(Entry.id == new_entry.id).delete() DBSession.flush() request.addfinalizer(teardown) return new_entry
def edit_post(request): entry_id = request.matchdict['id'] entry = DBSession.query(Entry).get(entry_id) form = EntryForm(request.POST, entry) if request.method == 'POST' and form.validate(): form.populate_obj(entry) DBSession.add(entry) DBSession.flush() url = request.route_url('entry', id=entry_id) return HTTPFound(url) return {'form': form}
def new_entry(request): """Create a fake entry.""" add_entry = Entry(title='heyheyhey', text='1111') DBSession.add(add_entry) DBSession.flush() def teardown(): DBSession.delete(add_entry) DBSession.flush() request.addfinalizer(teardown) return add_entry
def add_post(request): form = EntryForm(request.POST) if request.method == 'POST' and form.validate(): entry = Entry() entry.title = form.title.data entry.text = form.text.data DBSession.add(entry) DBSession.flush() entry_id = entry.id url = request.route_url('entry', id=entry_id) return HTTPFound(url) return {'form': form}
def new_entry(request): """Create a fake entry.""" add_entry = Entry(title='new stuff', text='content') DBSession.add(add_entry) DBSession.flush() def teardown(): DBSession.query(Entry).filter(Entry.id == add_entry.id).delete() DBSession.flush() request.addfinalizer(teardown) return add_entry
def new_entry(request, auth_env): """Create a fake entry.""" add_entry = Entry(title='heyheyhey', text='1111') DBSession.add(add_entry) DBSession.flush() def teardown(): DBSession.query(Entry).filter(Entry.id == add_entry.id).delete() DBSession.flush() request.addfinalizer(teardown) return add_entry
def dbtransaction(request, sqlengine): connection = sqlengine.connect() transaction = connection.begin() DBSession.configure(bind=connection) entry = Entry(title="testing 1", text="this is a test") DBSession.add(entry) DBSession.flush() def teardown(): transaction.rollback() connection.close() DBSession.remove() request.addfinalizer(teardown) return connection
def populate_db(json_for_post): post = Post(**json_for_post) DBSession.add(post) DBSession.flush()
def test_create_entry(dbtransaction): new_entry = Entry(title="Test Title", text="ipsum") assert new_entry.id is None DBSession.add(new_entry) DBSession.flush() assert new_entry.id is not None
def teardown(): DBSession.query(Entry).filter(Entry.id == new_entry.id).delete() DBSession.flush()
def new_entry(request, dbtransaction): """Return a new Entry and flush to the database.""" entry = Entry(title="test post", text="zomg testing") DBSession.add(entry) DBSession.flush() return entry
def teardown(): DBSession.delete(add_entry) DBSession.flush()
def loaded_db(dbtransaction): my_entry = Entry(title="thefreshloaf", text="the text about fresh loaves") DBSession.add(my_entry) DBSession.flush() return DBSession