Updating tests.

This commit is contained in:
Michael Lazar
2016-08-09 18:26:48 -07:00
parent d4cab22ffe
commit c096d7014c
4 changed files with 94 additions and 54 deletions

View File

@@ -4,14 +4,16 @@ from __future__ import unicode_literals
import os
import curses
import logging
import threading
from functools import partial
import praw
import pytest
from vcr import VCR
from six.moves.urllib.parse import urlparse, parse_qs
from six.moves.BaseHTTPServer import HTTPServer
from rtv.oauth import OAuthHelper
from rtv.oauth import OAuthHelper, OAuthHandler
from rtv.config import Config
from rtv.terminal import Terminal
from rtv.subreddit import SubredditPage
@@ -196,6 +198,21 @@ def oauth(reddit, terminal, config):
return OAuthHelper(reddit, terminal, config)
@pytest.yield_fixture()
def oauth_server():
# Start the OAuth server on a random port in the background
server = HTTPServer(('', 0), OAuthHandler)
server.url = 'http://{0}:{1}/'.format(*server.server_address)
thread = threading.Thread(target=server.serve_forever)
thread.start()
try:
yield server
finally:
server.shutdown()
thread.join()
server.server_close()
@pytest.fixture()
def submission_page(reddit, terminal, config, oauth):
submission = 'https://www.reddit.com/r/Python/comments/2xmo63'