def testRecipeLoadFile(): recipe = Recipe.loadFile("zlib-1.2.11.yaml") assert( recipe.name == "zlib" ) assert( recipe.version == "1.2.11" ) assert( recipe.check == ["test -r ${LIBDIR}/libz.so","test -r ${INCDIR}/zlib.h"] ) assert( len(recipe.install) == 5 ) assert( recipe.dependencies == [] )
def testRecipeDefaultDownload(): recipe = Recipe({"name":"test"}) assert(recipe.download == [])
def testRecipeValidStrCheck(): recipe = Recipe({"name":"test", "check":"command"}) assert(recipe.check[0] == "command")
def testRecipeValidListCheck(): recipe = Recipe({"name":"test", "check": ["command1","command2"]}) assert(recipe.check == ["command1","command2"])
def testRecipeDefaultCheck(): recipe = Recipe({"name":"test"}) assert(recipe.check == [])
def testRecipeValidStrInstall(): recipe = Recipe({"name":"test", "install":"command"}) assert(recipe.install[0] == "command")
def testRecipeNoName(): recipe = Recipe({})
def testRecipeInvalidDict(): recipe = Recipe("something")
def testRecipeValidStrDependencies(): recipe = Recipe({"name":"test", "dependencies": "blah"}) assert(recipe.dependencies == ["blah"] )
def testRecipeValidListDependencies(): recipe = Recipe({"name":"test", "dependencies": ["dep1","dep2"]}) assert(recipe.dependencies == ["dep1","dep2"])
def testRecipeDefaultDependencies(): recipe = Recipe({"name":"test"}) assert(recipe.dependencies == [])
def testRecipeValid(): recipe = Recipe({"name":"test", "version":"3.7"}) assert(recipe.name == "test") assert(recipe.version == "3.7")
def testRecipeDefaultVersion0(): recipe = Recipe({"name":"test"}) assert(recipe.version == "0")
def testRecipeEmptyName(): recipe = Recipe({"name":""})
def testRunRecipeFailedInstall(): recipe = Recipe({"name": "libtest", "version": "1.3", "check": ["test -f /usr/local/lib/libtest.so","test -f /usr/local/include/test.h"], "install":["wget http://test/test.tgz", "tar xzf test.tgz", "cd test && make install"] }) expected = [ call("test -f /usr/local/lib/libtest.so",shell=True), call("wget http://test/test.tgz",shell=True) ] with patch("subprocess.call", side_effect = [1,1] ) as mock: assert_raises( FailedRecipeError, runRecipe, recipe) assert( mock.mock_calls == expected )
def testRecipeDownloadList(): recipe = Recipe({"name":"test", "download":["http://domain.tld/file.tgz","http://domain.tld/anotherfile"]}) assert(recipe.download == ["http://domain.tld/file.tgz","http://domain.tld/anotherfile"])
def testRecipeDownloadSingle(): recipe = Recipe({"name":"test", "download":["http://domain.tld/file.tgz"]}) assert(recipe.download == ["http://domain.tld/file.tgz"])
def testRecipeDefaultInstall(): recipe = Recipe({"name":"test"}) assert(recipe.install == [])
def testRecipeValidListInstall(): recipe = Recipe({"name":"test", "install": ["command1","command2"]}) assert(recipe.install == ["command1","command2"])
def testRunRecipeCheckTrue(): recipe = Recipe({"name": "libtest", "version": "1.3", "check": ["test -f /usr/local/lib/libtest.so","test -f /usr/local/include/test.h"], "install":["wget http://test/test.tgz", "tar xzf test.tgz", "cd test && make install"] }) expected = [ call("test -f /usr/local/lib/libtest.so",shell=True) , call("test -f /usr/local/include/test.h",shell=True) ] with patch("subprocess.call", return_value = 0) as mock: runRecipe(recipe) assert( mock.mock_calls == expected )