import json
import os
import sys

import pytest
import six

import dcos.util as util
from dcos import mesos
from dcos.util import create_schema

from .helpers.common import (assert_command, assert_lines, exec_command,
                             fetch_valid_json, ssh_output)
from ..fixtures.node import slave_fixture


def test_help():
    with open('dcoscli/data/help/node.txt') as content:
        stdout = six.b(content.read())
    assert_command(['dcos', 'node', '--help'], stdout=stdout)


def test_info():
    stdout = b"View DC/OS node information\n"
    assert_command(['dcos', 'node', '--info'], stdout=stdout)


def test_node():
    returncode, stdout, stderr = exec_command(['dcos', 'node', '--json'])

    assert returncode == 0
    assert stderr == b''

    nodes = json.loads(stdout.decode('utf-8'))