# Path: tests/fixture_data.py
# PROJECT_DATA = {
#     'id': '000',
#     'name': 'nyan',
#     'description': 'nyan',
#     'owner': 1,
#     'ctime': '2016-12-16T12:25:52.718310Z',
#     'mtime': '2017-01-20T14:35:02.196871Z',
#     'urls': {
#         'display': 'https://app.valohai.com/p/nyan/nyan/',
#     }
# }
# 
# Path: valohai_cli/commands/project/list.py
# @click.command()
# def list() -> None:
#     """
#     List all projects.
#     """
#     projects_data = request('get', '/api/v0/projects/', params={'limit': 9000}).json()['results']
#     projects_data.sort(key=itemgetter('name'))
#     print_table(projects_data, ['name', 'description'])


import requests_mock
from tests.fixture_data import PROJECT_DATA
from valohai_cli.commands.project.list import list



def test_list(runner, logged_in):
    with requests_mock.mock() as m:
        m.get('https://app.valohai.com/api/v0/projects/', json={'results': [PROJECT_DATA]})
        result = runner.invoke(list)

# Path: tests/fixture_data.py
# PROJECT_DATA = {
#     'id': '000',
#     'name': 'nyan',
#     'description': 'nyan',
#     'owner': 1,
#     'ctime': '2016-12-16T12:25:52.718310Z',
#     'mtime': '2017-01-20T14:35:02.196871Z',
#     'urls': {
#         'display': 'https://app.valohai.com/p/nyan/nyan/',
#     }
# }
# 
# Path: valohai_cli/commands/project/list.py
# @click.command()
# def list() -> None:
#     """
#     List all projects.
#     """
#     projects_data = request('get', '/api/v0/projects/', params={'limit': 9000}).json()['results']
#     projects_data.sort(key=itemgetter('name'))
#     print_table(projects_data, ['name', 'description'])


# Path: tests/commands/project/test_list.py
import requests_mock
from tests.fixture_data import PROJECT_DATA
from valohai_cli.commands.project.list import list




def test_list(runner, logged_in):
    with requests_mock.mock() as m:
        m.get('https://app.valohai.com/api/v0/projects/', json={'results': [PROJECT_DATA]})
        result = runner.invoke(list)

        assert PROJECT_DATA['name'] in result.output