Example #1
0
    def take_action(self, parsed_args):
        column_headers = ('uuid', 'name', 'size', 'provider', 'status',
                          'start_date', 'end_date')
        api = AtmosphereAPI(self.app_args.auth_token,
                            base_url=self.app_args.base_url,
                            timeout=self.app_args.api_server_timeout,
                            verify=self.app_args.verify_cert)
        data = api.get_instance_history(parsed_args.id)
        history = []
        if data.ok:
            for status in data.message['results']:
                start_date = ts_to_date(status['start_date'])
                end_date = ''
                if status['end_date']:
                    end_date = ts_to_date(status['end_date'])
                history.append((
                    status['instance']['uuid'],
                    status['instance']['name'],
                    status['size']['name'],
                    status['provider']['name'],
                    status['status'],
                    start_date,
                    end_date,
                ))

        return (column_headers, tuple(history))
Example #2
0
 def test_getting_instance_history_when_response_is_ok(self):
     api = AtmosphereAPI('token', base_url=self.mock_users_base_url)
     response = api.get_instance_history('eb95b7e9-9c56-479b-9d81-b93292a9078a')
     assert response.ok
     assert response.message['count'] == 23 and response.message['results'][0]['status'] == 'build'
Example #3
0
 def test_getting_instance_history_when_response_is_not_ok(self):
     api = AtmosphereAPI('token', base_url=self.mock_users_bad_base_url)
     response = api.get_instance_history('eb95b7e9-9c56-479b-9d81-b93292a9078a')
     assert not response.ok