<s> import unittest <EOL> from conans . client . remote_manager import RemoteManager <EOL> from mock import Mock <EOL> from conans . errors import NotFoundException <EOL> from conans . model . ref import ConanFileReference , PackageReference <EOL> from conans . client . paths import ConanPaths <EOL> from conans . test . tools import TestBufferConanOutput , TestClient <EOL> from conans . test . utils . test_files import temp_folder <EOL> from conans . test . utils . cpp_test_files import cpp_hello_conan_files <EOL> from conans . client . remote_registry import Remote <EOL> class MockRemoteClient ( object ) : <EOL> def __init__ ( self ) : <EOL> self . upload_package = Mock ( ) <EOL> self . get_conan_digest = Mock ( ) <EOL> self . get_conanfile = Mock ( return_value = [ ( "<STR_LIT>" , "<STR_LIT>" ) ] ) <EOL> self . get_package = Mock ( return_value = [ ( "<STR_LIT>" , "<STR_LIT>" ) ] ) <EOL> self . remote_url = None <EOL> self . raise_count = <NUM_LIT:0> <EOL> def upload_conan ( self , * argc , ** argv ) : <EOL> if self . remote_url != "<STR_LIT>" : <EOL> self . raise_count += <NUM_LIT:1> <EOL> raise NotFoundException ( self . remote_url ) <EOL> else : <EOL> return self . remote_url <EOL> class RemoteManagerTest ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> self . conan_reference = ConanFileReference . loads ( "<STR_LIT>" ) <EOL> self . package_reference = PackageReference ( self . conan_reference , "<STR_LIT>" ) <EOL> self . remote_client = MockRemoteClient ( ) <EOL> self . output = TestBufferConanOutput ( ) <EOL> self . paths = ConanPaths ( temp_folder ( ) , temp_folder ( ) , self . output ) <EOL> self . remotes = [ ( "<STR_LIT:default>" , "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT>" ) ] <EOL> self . manager = RemoteManager ( self . paths , self . remote_client , self . output ) <EOL> def test_no_remotes ( self ) : <EOL> client = TestClient ( ) <EOL> files = cpp_hello_conan_files ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> client . save ( files ) <EOL> client . run ( "<STR_LIT>" ) <EOL> client . run ( "<STR_LIT>" , ignore_error = True ) <EOL> self . assertIn ( "<STR_LIT>" , client . user_io . out ) <EOL> def remote_selection_test ( self ) : <EOL> self . assertRaises ( NotFoundException , self . manager . upload_conan , self . conan_reference , <EOL> Remote ( "<STR_LIT>" , "<STR_LIT:url>" ) ) <EOL> self . assertRaises ( NotFoundException , <EOL> self . manager . upload_conan , self . conan_reference , Remote ( "<STR_LIT>" , "<STR_LIT:url>" ) ) <EOL> def method_called_test ( self ) : <EOL> self . assertFalse ( self . remote_client . upload_package . called ) <EOL> self . manager . upload_package ( self . package_reference , Remote ( "<STR_LIT>" , "<STR_LIT:url>" ) ) <EOL> self . assertTrue ( self . remote_client . upload_package . called ) <EOL> self . assertFalse ( self . remote_client . get_conan_digest . called ) <EOL> self . manager . get_conan_digest ( self . conan_reference , Remote ( "<STR_LIT>" , "<STR_LIT:url>" ) ) <EOL> self . assertTrue ( self . remote_client . get_conan_digest . called ) <EOL> self . assertFalse ( self . remote_client . get_conanfile . called ) <EOL> self . manager . get_conanfile ( self . conan_reference , Remote ( "<STR_LIT>" , "<STR_LIT:url>" ) ) <EOL> self . assertTrue ( self . remote_client . get_conanfile . called ) <EOL> self . assertFalse ( self . remote_client . get_package . called ) <EOL> self . manager . get_package ( self . package_reference , Remote ( "<STR_LIT>" , "<STR_LIT:url>" ) ) <EOL> self . assertTrue ( self . remote_client . get_package . called ) </s>
