<s> import unittest <EOL> import mock <EOL> from mock import patch <EOL> from JustReleaseNotes . issuers import GitHubIssues <EOL> import requests <EOL> import requests_mock <EOL> import JustReleaseNotes . issuers . AggregateIssuer <EOL> class DummyIssuer : <EOL> __ret = None <EOL> def __init__ ( self , value ) : <EOL> self . __ret = value <EOL> def extractTicketsFromMessage ( self , message ) : <EOL> return [ self . __ret ] if self . __ret in message else [ "<STR_LIT>" ] <EOL> def getTicketInfo ( self , ticket ) : <EOL> if self . __ret == ticket : <EOL> return { "<STR_LIT>" : self . __ret , "<STR_LIT:title>" : "<STR_LIT>" + self . __ret } <EOL> else : <EOL> raise <EOL> class GitHubIssues_Test ( unittest . TestCase ) : <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_extractTicketsFromMessage_ReturnsTicketsExtractedByEachOfIssuers ( self , mock_class ) : <EOL> mock_class . side_effect = [ DummyIssuer ( "<STR_LIT>" ) , DummyIssuer ( "<STR_LIT>" ) ] <EOL> config = [ { "<STR_LIT>" : "<STR_LIT>" } , { "<STR_LIT>" : "<STR_LIT>" } ] <EOL> issuer = JustReleaseNotes . issuers . AggregateIssuer . AggregateIssuer ( config ) <EOL> ret = issuer . extractTicketsFromMessage ( "<STR_LIT>" ) <EOL> self . assertIn ( "<STR_LIT>" , ret ) <EOL> self . assertIn ( "<STR_LIT>" , ret ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_getTicketInfo_ReturnsTicketsExtractedByEachOfIssuers ( self , mock_class ) : <EOL> mock_class . side_effect = [ DummyIssuer ( "<STR_LIT>" ) , DummyIssuer ( "<STR_LIT>" ) ] <EOL> config = [ { "<STR_LIT>" : "<STR_LIT>" } , { "<STR_LIT>" : "<STR_LIT>" } ] <EOL> issuer = JustReleaseNotes . issuers . AggregateIssuer . AggregateIssuer ( config ) <EOL> ret = issuer . getTicketInfo ( "<STR_LIT>" ) <EOL> self . assertIn ( "<STR_LIT>" , ret [ "<STR_LIT>" ] ) <EOL> self . assertIn ( "<STR_LIT>" , ret [ "<STR_LIT:title>" ] ) <EOL> ret = issuer . getTicketInfo ( "<STR_LIT>" ) <EOL> self . assertIn ( "<STR_LIT>" , ret [ "<STR_LIT>" ] ) <EOL> self . assertIn ( "<STR_LIT>" , ret [ "<STR_LIT:title>" ] ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_noIssuersReturnsNone ( self , mock_class ) : <EOL> mock_class . side_effect = [ ] <EOL> config = [ ] <EOL> issuer = JustReleaseNotes . issuers . AggregateIssuer . AggregateIssuer ( config ) <EOL> ret = issuer . getTicketInfo ( "<STR_LIT>" ) <EOL> self . assertEqual ( None , ret ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
