Skip to content

Commit

Permalink
Renamed and minor updates to CLI tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffrimko committed Dec 17, 2017
1 parent 916101f commit fbf451e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 38 deletions.
4 changes: 2 additions & 2 deletions tests/cli_test_3.py → tests/cli_check_test_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

class TestCase(BaseTest):

def test_cli_1(test):
def test_cli_check_1(test):
retval = call('check --inpath ./templates/t5.jinja2')
test.assertEqual(0, retval)

def test_cli_2(test):
def test_cli_check_2(test):
retval = call('check')
test.assertEqual(1, retval)

Expand Down
58 changes: 25 additions & 33 deletions tests/cli_test_1.py → tests/cli_make_test_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,117 +12,109 @@

class TestCase(BaseTest):

def test_cli_1(test):
def test_cli_make_1(test):
errcode = call("make --inpath ./templates/t1.jinja2 --outpath %s --string name Mister" % (OUTFILE))
test.assertEqual(0, errcode)
test.assertEqual(File(OUTFILE).read(), "Hello Mister!")

def test_cli_2(test):
def test_cli_make_2(test):
args = "--string name::first Mister --string name::last Bob"
errcode = call("make --inpath ./templates/t2.jinja2 --outpath %s %s" % (OUTFILE, args))
test.assertEqual(0, errcode)
test.assertEqual(File(OUTFILE).read(), "Hello Mister Bob!")

def test_cli_3(test):
def test_cli_make_3(test):
args = "--string num five --string name::first Mister --string name::last Bob"
errcode = call("make --inpath ./templates/t3.jinja2 --outpath %s %s" % (OUTFILE, args))
test.assertEqual(0, errcode)
test.assertEqual(File(OUTFILE).read(), "Hello Mister Bob, high five!")

def test_cli_4(test):
def test_cli_make_4(test):
args = "--defaults ./defaults/d1.yaml"
errcode = call("make --inpath ./templates/t3.jinja2 --outpath %s %s" % (OUTFILE, args))
test.assertEqual(0, errcode)
test.assertEqual(File(OUTFILE).read(), "Hello Mister Bob, high five!")

def test_cli_5(test):
def test_cli_make_5(test):
args = "--defaults ./defaults/d2.yaml"
errcode = call("make --inpath ./templates/t4.jinja2 --outpath %s %s" % (OUTFILE, args))
test.assertEqual(0, errcode)
test.assertEqual(File(OUTFILE).read(), "foo,bar,baz")

def test_cli_6(test):
def test_cli_make_6(test):
args = "--defaults ./defaults/d3.yaml"
errcode = call("make --inpath ./templates/t2.jinja2 --outpath %s %s" % (OUTFILE, args))
test.assertEqual(0, errcode)
test.assertEqual(File(OUTFILE).read(), "Hello Mister Bob!")

def test_cli_7(test):
def test_cli_make_7(test):
errcode = call("make --defaults ./defaults/d4.yaml")
test.assertEqual(0, errcode)
test.assertTrue(op.isfile("./__output__/out.py"))

def test_cli_8(test):
def test_cli_make_8(test):
errcode = call("make")
test.assertEqual(1, errcode)

def test_cli_9(test):
def test_cli_make_9(test):
errcode = call("make --defaults ./defaults/d5.yaml")
test.assertEqual(0, errcode)
test.assertTrue(op.isfile("./__output__/out.py"))

def test_cli_10(test):
def test_cli_make_10(test):
errcode = call("make --defaults defaults-d1.yaml")
test.assertEqual(0, errcode)
test.assertTrue(op.isfile("./__output__/out.py"))

def test_cli_11(test):
def test_cli_make_11(test):
errcode = call("make --defaults defaults/d6.yaml")
test.assertEqual(0, errcode)
test.assertTrue(op.isdir("./__output__/foo"))
test.assertTrue(op.isfile("./__output__/foo/bar.txt"))

def test_cli_12(test):
def test_cli_make_12(test):
errcode = call("make --defaults defaults/d6.yaml --string mydir baz")
test.assertEqual(0, errcode)
test.assertTrue(op.isdir("./__output__/baz"))
test.assertTrue(op.isfile("./__output__/baz/bar.txt"))

def test_cli_13(test):
def test_cli_make_13(test):
errcode = call("make --defaults defaults/d6.yaml --outpath __output__/baz")
test.assertEqual(0, errcode)
test.assertTrue(op.isdir("./__output__/baz/foo"))
test.assertTrue(op.isfile("./__output__/baz/foo/bar.txt"))

def test_cli_14(test):
def test_cli_make_14(test):
with Cwd("__output__"):
errcode = call("make --defaults ../defaults/d7.yaml", app_path="../../app")
test.assertEqual(0, errcode)
test.assertTrue(op.isdir("./foo"))
test.assertTrue(op.isfile("./foo/bar.txt"))
test.assertEqual(File("./foo/bar.txt").read(), "hello baz!")

def test_cli_15(test):
with Cwd("__output__"):
errcode = call("../defaults/d7.yaml", app_path="../../app")
test.assertEqual(0, errcode)
test.assertTrue(op.isdir("./foo"))
test.assertTrue(op.isfile("./foo/bar.txt"))
test.assertEqual(File("./foo/bar.txt").read(), "hello baz!")

def test_cli_16(test):
errcode = call("defaults/d8.yaml")
test.assertEqual(0, errcode)

def test_cli_17(test):
errcode = call("defaults/d9.yaml")
test.assertEqual(0, errcode)

def test_cli_18(test):
def test_cli_make_15(test):
with Cwd("templates"):
errcode = call("make --inpath foo", app_path="../../app")
test.assertEqual(1, errcode)

def test_cli_19(test):
def test_cli_make_16(test):
with Cwd("templates"):
errcode = call("make --inpath t1.jinja2", app_path="../../app")
test.assertEqual(0, errcode)

def test_cli_20(test):
def test_cli_make_17(test):
with Cwd("templates"):
errcode = call("make --inpath t1.jinja2 --outpath t1.jinja2", app_path="../../app")
test.assertEqual(1, errcode)

def test_cli_make_18(test):
with Cwd("__output__"):
errcode = call("../defaults/d7.yaml", app_path="../../app")
test.assertEqual(0, errcode)
test.assertTrue(op.isdir("./foo"))
test.assertTrue(op.isfile("./foo/bar.txt"))
test.assertEqual(File("./foo/bar.txt").read(), "hello baz!")

##==============================================================#
## SECTION: Main Body #
##==============================================================#
Expand Down
8 changes: 5 additions & 3 deletions tests/cli_test_2.py → tests/cli_run_test_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@

class TestCase(BaseTest):

def test_cli_1(test):
retval = call('run --inpath ./templates/t5.jinja2 --outpath out.py --execute "python {{outpath}}" --string filename foo.txt --string text bar')
def test_cli_run_1(test):
cmd = 'run --inpath ./templates/t5.jinja2 --outpath out.py --execute "python {{outpath}}"'
cmd += ' --string filename foo.txt --string text bar'
retval = call(cmd)
test.assertEqual(0, retval)
test.assertTrue(op.isfile("__output__/foo.txt"))
test.assertFalse(op.isfile("__output__/out.py"))
test.assertEqual(File("__output__/foo.txt").read(), "bar")

def test_cli_2(test):
def test_cli_run_2(test):
retval = call("run --defaults defaults/d4.yaml")
test.assertEqual(0, retval)
test.assertTrue(op.isfile("__output__/foo.txt"))
Expand Down

0 comments on commit fbf451e

Please sign in to comment.