import pytest
import subprocess


def test_help(tmpdir, cli):
    with cli(
        args=['ceph-deploy', 'osd', '--help'],
        stdout=subprocess.PIPE,
        ) as p:
        result = p.stdout.read()
    assert 'usage: ceph-deploy osd' in result
    assert 'positional arguments' in result
    assert 'optional arguments' in result


def test_bad_subcommand(tmpdir, cli):
    with pytest.raises(cli.Failed) as err:
        with cli(
            args=['ceph-deploy', 'osd', 'fakehost:/does-not-exist'],
            stderr=subprocess.PIPE,
            ) as p:
            result = p.stderr.read()
    assert 'ceph-deploy osd: error' in result
    assert 'invalid choice' in result
    assert err.value.status == 2


def test_bad_no_disk(tmpdir, cli):
    with tmpdir.join('ceph.conf').open('w'):
        pass
    with pytest.raises(cli.Failed) as err:
        with cli(
            args=['ceph-deploy', 'osd'],
            stderr=subprocess.PIPE,
            ) as p:
            result = p.stderr.read()
    assert 'usage: ceph-deploy osd' in result
    assert 'too few arguments' in result
    assert err.value.status == 2

import pytest
import subprocess


def test_help(tmpdir, cli):
    with cli(
        args=['ceph-deploy', 'osd', '--help'],
        stdout=subprocess.PIPE,
        ) as p:
        result = p.stdout.read()
    assert 'usage: ceph-deploy osd' in result
    assert 'positional arguments' in result
    assert 'optional arguments' in result


def test_bad_subcommand(tmpdir, cli):
    with pytest.raises(cli.Failed) as err:
        with cli(
            args=['ceph-deploy', 'osd', 'fakehost:/does-not-exist'],
            stderr=subprocess.PIPE,
            ) as p:
            result = p.stderr.read()
    assert 'ceph-deploy osd: error' in result
    assert 'invalid choice' in result
    assert err.value.status == 2


def test_bad_no_disk(tmpdir, cli):
    with pytest.raises(cli.Failed) as err:
        with cli(
            args=['ceph-deploy', 'osd'],
            stderr=subprocess.PIPE,
            ) as p:
            result = p.stderr.read()
    assert 'usage: ceph-deploy osd' in result
    assert 'too few arguments' in result
    assert err.value.status == 2

Remove unneeded creation of .conf file
[RM-11742] Remove unneeded creation of .conf file

Signed-off-by: Travis Rhoden <e5e44d6dbac12e32e01c3bb8b67940d8b42e225b@redhat.com>

  import pytest
  import subprocess
  
  
  def test_help(tmpdir, cli):
      with cli(
          args=['ceph-deploy', 'osd', '--help'],
          stdout=subprocess.PIPE,
          ) as p:
          result = p.stdout.read()
      assert 'usage: ceph-deploy osd' in result
      assert 'positional arguments' in result
      assert 'optional arguments' in result
  
  
  def test_bad_subcommand(tmpdir, cli):
      with pytest.raises(cli.Failed) as err:
          with cli(
              args=['ceph-deploy', 'osd', 'fakehost:/does-not-exist'],
              stderr=subprocess.PIPE,
              ) as p:
              result = p.stderr.read()
      assert 'ceph-deploy osd: error' in result
      assert 'invalid choice' in result
      assert err.value.status == 2
  
  
  def test_bad_no_disk(tmpdir, cli):
-     with tmpdir.join('ceph.conf').open('w'):
-         pass
      with pytest.raises(cli.Failed) as err:
          with cli(
              args=['ceph-deploy', 'osd'],
              stderr=subprocess.PIPE,
              ) as p:
              result = p.stderr.read()
      assert 'usage: ceph-deploy osd' in result
      assert 'too few arguments' in result
      assert err.value.status == 2
  
Remove unneeded creation of .conf file
## Code Before:
import pytest
import subprocess


def test_help(tmpdir, cli):
    with cli(
        args=['ceph-deploy', 'osd', '--help'],
        stdout=subprocess.PIPE,
        ) as p:
        result = p.stdout.read()
    assert 'usage: ceph-deploy osd' in result
    assert 'positional arguments' in result
    assert 'optional arguments' in result


def test_bad_subcommand(tmpdir, cli):
    with pytest.raises(cli.Failed) as err:
        with cli(
            args=['ceph-deploy', 'osd', 'fakehost:/does-not-exist'],
            stderr=subprocess.PIPE,
            ) as p:
            result = p.stderr.read()
    assert 'ceph-deploy osd: error' in result
    assert 'invalid choice' in result
    assert err.value.status == 2


def test_bad_no_disk(tmpdir, cli):
    with tmpdir.join('ceph.conf').open('w'):
        pass
    with pytest.raises(cli.Failed) as err:
        with cli(
            args=['ceph-deploy', 'osd'],
            stderr=subprocess.PIPE,
            ) as p:
            result = p.stderr.read()
    assert 'usage: ceph-deploy osd' in result
    assert 'too few arguments' in result
    assert err.value.status == 2

## Instruction:
Remove unneeded creation of .conf file
## Code After:
import pytest
import subprocess


def test_help(tmpdir, cli):
    with cli(
        args=['ceph-deploy', 'osd', '--help'],
        stdout=subprocess.PIPE,
        ) as p:
        result = p.stdout.read()
    assert 'usage: ceph-deploy osd' in result
    assert 'positional arguments' in result
    assert 'optional arguments' in result


def test_bad_subcommand(tmpdir, cli):
    with pytest.raises(cli.Failed) as err:
        with cli(
            args=['ceph-deploy', 'osd', 'fakehost:/does-not-exist'],
            stderr=subprocess.PIPE,
            ) as p:
            result = p.stderr.read()
    assert 'ceph-deploy osd: error' in result
    assert 'invalid choice' in result
    assert err.value.status == 2


def test_bad_no_disk(tmpdir, cli):
    with pytest.raises(cli.Failed) as err:
        with cli(
            args=['ceph-deploy', 'osd'],
            stderr=subprocess.PIPE,
            ) as p:
            result = p.stderr.read()
    assert 'usage: ceph-deploy osd' in result
    assert 'too few arguments' in result
    assert err.value.status == 2
