from __future__ import (absolute_import, division, print_function)

import subprocess
import tempfile


def test_call():
    output = subprocess.check_output(['yaml2ncml', 'roms_0.yaml'])
    with open('base_roms_test.ncml') as f:
        expected = f.read()
    assert output.decode() == expected


def test_save_file():
    outfile = tempfile.mktemp(suffix='.ncml')
    subprocess.call(['yaml2ncml',
                     'roms_0.yaml',
                     '--output={}'.format(outfile)])
    with open('base_roms_test.ncml') as f:
        expected = f.read()
    with open(outfile) as f:
        output = f.read()
    assert output == expected

@@ -96,16 +96,87 @@
 mpfile%0A%0A
+import pytest%0Aimport ruamel.yaml as yaml%0A%0Afrom yaml2ncml import build%0A%0A
 %0Adef tes
@@ -699,20 +699,310 @@
  output == expected%0A
+%0A%0A@pytest.fixture%0Adef load_ymal(fname='roms_1.yaml'):%0A    with open(fname, 'r') as stream:%0A        yml = yaml.load(stream, Loader=yaml.RoundTripLoader)%0A    return yml%0A%0A%0Adef test_bad_yaml():%0A    with pytest.raises(ValueError):%0A        yml = load_ymal(fname='roms_1.yaml')%0A        build(yml)%0A

Test bad call/better error msg