def test_add_quotes(database, mention, quote, time, new_id, expected, db_size): add_quote(mention, quote, time, database) q = quotes_query(new_id, database).one_or_none() actual = quote_str(q) assert actual == expected assert database.query(Quote).count() == db_size
def test_optout(database, is_exec, requester, target, expected, oo_size, q_size): if target is None: target = requester actual = opt_out_of_quotes(is_exec, requester, target, database) try: add_quote(target, "quote thingy", datetime.now(), database) except QuoteException as e: assert e.err == QuoteError.OPTED_OUT assert actual == expected assert database.query(QuoteOptouts).count() == oo_size assert database.query(Quote).count() == q_size
def test_optin(database, requester, try_quote, oo_size, q_size): opt_in_to_quotes(requester, database) actual_from_quote = add_quote(requester, "quote thingy", datetime.now(), database) assert database.query(QuoteOptouts).count() == oo_size assert actual_from_quote == try_quote assert database.query(Quote).count() == q_size
def test_optin_fails(database, requester, try_quote, oo_size, q_size): with pytest.raises(QuoteException) as e: opt_in_to_quotes(requester, database) actual_from_quote = add_quote(requester, "quote thingy", datetime.now(), database) assert e.value.err == QuoteError.NO_OP assert database.query(QuoteOptouts).count() == oo_size assert actual_from_quote == try_quote assert database.query(Quote).count() == q_size
def test_add_fails(database, mention, quote, time, error, db_size): with pytest.raises(QuoteException) as e: add_quote(mention, quote, time, database) assert e.value.err == error assert database.query(Quote).count() == db_size