def do_list(self, args, global_args): """List all application resources.""" self._output_formatter(global_args) rm = AppManager() try: rm.list() except HttpReturnError as e: self.out.error(e.args[1]) sys.exit(1) # FIXME: The formatting should not happen here I guess for item in rm._collection.collection_set: self.out.info(item.name)
def test_app_manager_list(self): rm = AppManager() msg = { "size": 2, "items": [ {"name": "name1"}, {"name": "name2"} ]} response = Mock() response.status_code = 200 response.content = json.dumps(msg) self.mock_requests.request.return_value = response rm.list() self.mock_requests.request.assert_called_once_with( url=rm.uri(), method='get', verify='/path/ssl/StartSSL_CA.pem', ) eq_(2, len(rm._collection.collection_set))