<s> """<STR_LIT>""" <EOL> import unittest <EOL> from mockito import * <EOL> from ice . gridproviders . combined_provider import CombinedProvider <EOL> class CombinedProviderTests ( unittest . TestCase ) : <EOL> def test_is_enabled_returns_false_when_no_providers_are_enabled ( self ) : <EOL> provider1 = mock ( ) <EOL> when ( provider1 ) . is_enabled ( ) . thenReturn ( False ) <EOL> provider2 = mock ( ) <EOL> when ( provider2 ) . is_enabled ( ) . thenReturn ( False ) <EOL> combined_provider = CombinedProvider ( provider1 , provider2 ) <EOL> self . assertFalse ( combined_provider . is_enabled ( ) ) <EOL> def test_is_enabled_returns_true_if_at_least_one_provider_is_enabled ( self ) : <EOL> provider1 = mock ( ) <EOL> when ( provider1 ) . is_enabled ( ) . thenReturn ( False ) <EOL> provider2 = mock ( ) <EOL> when ( provider2 ) . is_enabled ( ) . thenReturn ( True ) <EOL> combined_provider = CombinedProvider ( provider1 , provider2 ) <EOL> self . assertTrue ( combined_provider . is_enabled ( ) ) <EOL> def test_image_for_rom_returns_image_from_earlier_provider_first ( self ) : <EOL> rom = mock ( ) <EOL> image1 = mock ( ) <EOL> provider1 = mock ( ) <EOL> when ( provider1 ) . is_enabled ( ) . thenReturn ( True ) <EOL> when ( provider1 ) . image_for_rom ( rom ) . thenReturn ( image1 ) <EOL> image2 = mock ( ) <EOL> provider2 = mock ( ) <EOL> when ( provider2 ) . is_enabled ( ) . thenReturn ( True ) <EOL> when ( provider2 ) . image_for_rom ( rom ) . thenReturn ( image2 ) <EOL> combined_provider = CombinedProvider ( provider1 , provider2 ) <EOL> self . assertEquals ( combined_provider . image_for_rom ( rom ) , image1 ) <EOL> def test_image_for_rom_returns_image_from_later_provider_when_first_returns_none ( self ) : <EOL> rom = mock ( ) <EOL> provider1 = mock ( ) <EOL> when ( provider1 ) . is_enabled ( ) . thenReturn ( True ) <EOL> when ( provider1 ) . image_for_rom ( rom ) . thenReturn ( None ) <EOL> image2 = mock ( ) <EOL> provider2 = mock ( ) <EOL> when ( provider2 ) . is_enabled ( ) . thenReturn ( True ) <EOL> when ( provider2 ) . image_for_rom ( rom ) . thenReturn ( image2 ) <EOL> image3 = mock ( ) <EOL> provider3 = mock ( ) <EOL> when ( provider3 ) . is_enabled ( ) . thenReturn ( True ) <EOL> when ( provider3 ) . image_for_rom ( rom ) . thenReturn ( image3 ) <EOL> combined_provider = CombinedProvider ( provider1 , provider2 , provider3 ) <EOL> self . assertEquals ( combined_provider . image_for_rom ( rom ) , image2 ) <EOL> def test_image_for_rom_skips_disabled_providers ( self ) : <EOL> rom = mock ( ) <EOL> image1 = mock ( ) <EOL> provider1 = mock ( ) <EOL> when ( provider1 ) . is_enabled ( ) . thenReturn ( False ) <EOL> when ( provider1 ) . image_for_rom ( rom ) . thenReturn ( image1 ) <EOL> image2 = mock ( ) <EOL> provider2 = mock ( ) <EOL> when ( provider2 ) . is_enabled ( ) . thenReturn ( True ) <EOL> when ( provider2 ) . image_for_rom ( rom ) . thenReturn ( image2 ) <EOL> combined_provider = CombinedProvider ( provider1 , provider2 ) <EOL> self . assertEquals ( combined_provider . image_for_rom ( rom ) , image2 ) </s>
