<s> import json <EOL> import os <EOL> from unittest import TestCase <EOL> try : <EOL> from urlparse import urlparse <EOL> except ImportError : <EOL> from urllib . parse import urlparse <EOL> from requests . models import Response <EOL> from mock import patch <EOL> from stashy . client import StashClient <EOL> from stashy . pullrequests import PullRequest <EOL> def fake_urlopen ( stash_client , url ) : <EOL> """<STR_LIT>""" <EOL> parsed_url = urlparse ( url ) <EOL> resource_file = os . path . normpath ( <EOL> '<STR_LIT>' % ( os . path . dirname ( os . path . abspath ( __file__ ) ) , parsed_url . path ) ) <EOL> resp = Response ( ) <EOL> resp . status_code = <NUM_LIT:200> <EOL> resp . json = lambda : json . loads ( open ( resource_file , mode = '<STR_LIT:rb>' ) . read ( ) . decode ( '<STR_LIT:utf-8>' ) ) <EOL> return resp <EOL> class TestPullRequest ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . client = StashClient ( "<STR_LIT>" ) <EOL> @ patch ( '<STR_LIT>' , fake_urlopen ) <EOL> def test_can_merge ( self ) : <EOL> pr = PullRequest ( <NUM_LIT:1> , '<STR_LIT>' , self . client , None ) <EOL> assert pr . can_merge ( ) is False <EOL> @ patch ( '<STR_LIT>' , fake_urlopen ) <EOL> def test_merge_vetoes ( self ) : <EOL> pr = PullRequest ( <NUM_LIT:1> , '<STR_LIT>' , self . client , None ) <EOL> vetoes = pr . merge_info ( ) <EOL> assert len ( vetoes [ '<STR_LIT>' ] ) == <NUM_LIT:1> </s>
