1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
# -*- coding: utf-8 -*-
""" Test the OpenIdBaseClient. """
import os
import shutil
import tempfile
import unittest
from fedora.client import FedoraServiceError
from fedora.client.openidbaseclient import OpenIdBaseClient
BASE_URL = 'http://127.0.0.1:5000'
BASE_URL = 'http://209.132.184.188'
LOGIN_URL = '{}/login/'.format(BASE_URL)
class OpenIdBaseClientTest(unittest.TestCase):
"""Test the OpenId Base Client."""
def setUp(self):
self.client = OpenIdBaseClient(BASE_URL)
self.session_file = os.path.expanduser(
'~/.fedora/baseclient-sessions.sqlite')
try:
self.backup_dir = tempfile.mkdtemp(dir='~/.fedora/')
except OSError:
self.backup_dir = tempfile.mkdtemp()
self.saved_session_file = os.path.join(
self.backup_dir, 'baseclient-sessions.sqlite.bak')
self.clear_cookies()
def tearDown(self):
self.restore_cookies()
shutil.rmtree(self.backup_dir)
def clear_cookies(self):
try:
shutil.move(self.session_file, self.saved_session_file)
except IOError as e:
# No previous sessionfile is fine
if e.errno != 2:
raise
# Sentinel to say that there was no previous session_file
self.saved_session_file = None
def restore_cookies(self):
if self.saved_session_file:
shutil.move(self.saved_session_file, self.session_file)
|