def _patch_client(plugins, download_path=None, concurrent=False): plugins = [Plugin(p) for p in plugins] client = (MockConcurrentClinet(plugins, download_path=download_path) if concurrent else MockClient(plugins, download_path=download_path)) with patch('cloudify_agent.api.plugins.installer.get_rest_client', lambda: client): yield client
def _patch(self, plugins): plugins = [Plugin(p) for p in plugins] client = TestGetManagedPlugin.Client(plugins) get_rest_client = lambda: client with patch('cloudify_agent.api.plugins.installer.get_rest_client', get_rest_client): yield client
def test_plugin_get(self): self.client.plugins.get = MagicMock( return_value=Plugin({ 'id': 'id', 'package_name': 'dummy', 'package_version': '1.2', 'supported_platform': 'any', 'distribution_release': 'trusty', 'distribution': 'ubuntu', 'uploaded_at': 'now' })) cli_runner.run_cli('cfy plugins get -p some_id')
def _patch_client(plugins, download_path=None): plugins = [Plugin(p) for p in plugins] client = MockClient(plugins, download_path=download_path) with patch('cloudify_agent.api.plugins.installer.get_rest_client', lambda: client): yield client