<s> from __future__ import absolute_import <EOL> from __future__ import unicode_literals <EOL> import contextlib <EOL> import mock <EOL> import pytest <EOL> from git_code_debt . generate import main <EOL> from git_code_debt . server . app import app <EOL> from git_code_debt . server . app import AppContext <EOL> from testing . utilities . auto_namedtuple import auto_namedtuple <EOL> from testing . utilities . client import Client <EOL> class GitCodeDebtServer ( object ) : <EOL> def __init__ ( self , client , sandbox ) : <EOL> self . client = client <EOL> self . sandbox = sandbox <EOL> @ contextlib . contextmanager <EOL> def _patch_app_with_client ( application ) : <EOL> with mock . patch . object ( application , '<STR_LIT>' , Client ) : <EOL> with mock . patch . object ( <EOL> type ( application ) , '<STR_LIT>' , mock . PropertyMock ( return_value = True ) , <EOL> ) : <EOL> yield <EOL> @ contextlib . contextmanager <EOL> def _in_testing_app_context ( application ) : <EOL> with application . test_request_context ( ) : <EOL> with application . test_client ( ) as client : <EOL> yield client <EOL> @ pytest . yield_fixture <EOL> def server ( sandbox ) : <EOL> with _patch_app_with_client ( app ) : <EOL> with _in_testing_app_context ( app ) as client : <EOL> with mock . patch . object ( <EOL> AppContext , '<STR_LIT>' , sandbox . db_path , <EOL> ) : <EOL> yield GitCodeDebtServer ( client , sandbox ) <EOL> @ pytest . yield_fixture <EOL> def server_with_data ( server , cloneable_with_commits ) : <EOL> main ( [ cloneable_with_commits . path , server . sandbox . db_path ] ) <EOL> yield auto_namedtuple ( <EOL> server = server , <EOL> cloneable_with_commits = cloneable_with_commits , <EOL> ) </s>
