示例#1
0
 def test_recursive_dir_bad_recursive_mode(self, tmpdir):
     dir_path, _1, _2 = make_files(tmpdir, "mygame")
     make_files(dir_path, "some other game")
     out_dir = tmpdir.mkdir("output")
     g = Gdipak()
     with pytest.raises(ValueError):
         g.pack_gdi(dir_path, out_dir, "strawberry", False)
示例#2
0
 def test_recursive_dir_same_out_dir_mode_zero(self, tmpdir):
     dir_path, _1, exts = make_files(tmpdir, "mygame")
     make_files(dir_path, "some other game")
     g = Gdipak()
     g.pack_gdi(dir_path, dir_path, RecursiveMode.PRESERVE_STRUCTURE, False)
     check_files(dir_path, exts)
     with scandir(dir_path) as itr:
         for item in itr:
             if path.isdir(item):
                 check_files(item, exts)
示例#3
0
 def test_recursive_dir_same_out_dir_mode_one(self, tmpdir):
     dir_path, _1, exts = make_files(tmpdir, "mygame")
     make_files(dir_path, "some other game")
     g = Gdipak()
     # mode is changed implicitly due to in_dir == out_dir
     g.pack_gdi(dir_path, dir_path, RecursiveMode.FLAT_STRUCTURE, False)
     check_files(dir_path, exts)
     with scandir(dir_path) as itr:
         for item in itr:
             if path.isdir(item):
                 check_files(item, exts)
示例#4
0
 def test_recursive_dir_same_out_dir_mode_none(self, tmpdir):
     dir_path, _1, exts = make_files(tmpdir, "mygame")
     make_files(dir_path, "some other game")
     g = Gdipak()
     g.pack_gdi(dir_path, dir_path, None, False)
     check_files(dir_path, exts)
     with scandir(dir_path) as itr:
         for item in itr:
             if path.isdir(item):
                 # subdir was not touched
                 with pytest.raises(AssertionError):
                     check_files(item, exts)
示例#5
0
 def test_too_many_gdi_files(self, tmpdir):
     name = "mygame"
     dir_path, _1, _2 = make_files(tmpdir, name)
     f = dir_path.join("who put this file here.gdi")
     f.write("")
     g = Gdipak()
     with pytest.raises(ValueError):
         g.pack_gdi(dir_path, dir_path)
示例#6
0
 def test_missing_gdi_file(self, tmpdir):
     name = "mygame"
     dir_path, _1, _2 = make_files(tmpdir, name)
     gdi_path = pypath.local(path.join(dir_path, name + ".gdi"))
     gdi_path.remove()
     g = Gdipak()
     with pytest.raises(ValueError):
         g.pack_gdi(dir_path, dir_path)
示例#7
0
    def test_single_dir_same_out_dir_default_args(self, tmpdir):
        dir_path, _1, exts = make_files(tmpdir, "mygame")
        g = Gdipak()
        g.pack_gdi(dir_path, dir_path)

        #dir name didn't change
        assert (tmpdir.listdir()[0] == dir_path)
        check_files(dir_path, exts)
示例#8
0
    def test_recursive_dir_different_out_dir_mode_zero(self, tmpdir):
        sg_dir, _1, sg_exts = make_files(tmpdir, "some game")
        sog_dir, _1, sog_exts = make_files(sg_dir, "some other game")
        soog_dir, _1, soog_exts = make_files(sg_dir, "some other other game")
        sooog_dir, _1, sooog_exts = make_files(soog_dir,
                                               "some other other other game")
        out_dir = tmpdir.mkdir("processed_game")
        g = Gdipak()
        g.pack_gdi(sg_dir, out_dir, RecursiveMode.PRESERVE_STRUCTURE)

        sg_dir_path = path.join(out_dir, path.basename(sg_dir))
        check_files(sg_dir_path, sg_exts)
        sog_dir_path = path.join(sg_dir_path, path.basename(sog_dir))
        check_files(sog_dir_path, sog_exts)
        soog_dir_path = path.join(sg_dir_path, path.basename(soog_dir))
        check_files(soog_dir_path, soog_exts)
        sooog_dir_path = path.join(soog_dir_path, path.basename(sooog_dir))
        check_files(sooog_dir_path, sooog_exts)
示例#9
0
    def test_recursive_dir_same_out_dir(self, tmpdir, monkeypatch):
        sg_dir, _1, sg_exts = make_files(tmpdir, "some game")
        sog_dir, _1, sog_exts = make_files(sg_dir, "some other game")
        soog_dir, _1, soog_exts = make_files(sg_dir, "some other other game")
        sooog_dir, _1, sooog_exts = make_files(soog_dir,
                                               "some other other other game")

        monkeypatch.setattr("gdipak.argv", ["pytest", "-d", str(sg_dir), "-m"])
        gdipak.main()

        sg_dir_path = path.join(tmpdir, path.basename(sg_dir))
        check_files(sg_dir_path, sg_exts)
        sog_dir_path = path.join(sg_dir, path.basename(sog_dir))
        check_files(sog_dir_path, sog_exts)
        soog_dir_path = path.join(sg_dir, path.basename(soog_dir))
        check_files(soog_dir_path, soog_exts)
        sooog_dir_path = path.join(soog_dir, path.basename(sooog_dir))
        check_files(sooog_dir_path, sooog_exts)
示例#10
0
    def test_single_dir_different_out_dir(self, tmpdir):
        in_dir, in_filenames, exts = make_files(tmpdir, "mygame")
        out_dir = tmpdir.mkdir("processed_game")
        g = Gdipak()
        g.pack_gdi(in_dir, out_dir)

        #src files didn't change
        with scandir(in_dir) as itr:
            for item in itr:
                assert (path.basename(item) in in_filenames)
        dir_path = path.join(out_dir, path.basename(in_dir))
        check_files(dir_path, exts)
示例#11
0
    def test_recursive_dir_different_out_dir_mode_zero(self, tmpdir,
                                                       monkeypatch):
        sg_dir, _1, sg_exts = make_files(tmpdir, "some game")
        sog_dir, _1, sog_exts = make_files(sg_dir, "some other game")
        soog_dir, _1, soog_exts = make_files(sg_dir, "some other other game")
        sooog_dir, _1, sooog_exts = make_files(soog_dir,
                                               "some other other other game")
        out_dir = tmpdir.mkdir("processed_game")

        monkeypatch.setattr(
            "gdipak.argv",
            ["pytest", "-d",
             str(sg_dir), "-o",
             str(out_dir), "-r", "0"])
        gdipak.main()

        sg_dir_path = path.join(out_dir, path.basename(sg_dir))
        check_files(sg_dir_path, sg_exts)
        sog_dir_path = path.join(sg_dir_path, path.basename(sog_dir))
        check_files(sog_dir_path, sog_exts)
        soog_dir_path = path.join(sg_dir_path, path.basename(soog_dir))
        check_files(soog_dir_path, soog_exts)
        sooog_dir_path = path.join(soog_dir_path, path.basename(sooog_dir))
        check_files(sooog_dir_path, sooog_exts)