0aeada3c9a197050c08a3292ec98a5db4b05e831
Hanno Böck add test with online testdata

Hanno Böck authored 4 years ago

1) import unittest
2) import subprocess
3) import glob
4) import os
5) import tempfile
6) import shutil
7) import re
8) import difflib
9) 
10) TESTDATA_REPO = "https://github.com/schokokeksorg/freewvs-testdata"
11) 
12) 
13) class TestFreewvsData(unittest.TestCase):
14)     @unittest.skipUnless(os.environ.get("FREEWVS_ONLINETESTS"),
15)                          "Not running online tests")
16)     def test_freewvs_testdata(self):
17)         tmp = tempfile.mkdtemp(prefix="freewvs-testdata")
18)         if os.environ.get("FREEWVS_TESTDATA_REPOSITORY"):
19)             os.symlink(os.environ.get("FREEWVS_TESTDATA_REPOSITORY"),
20)                        tmp + "/freewvs-testdata")
21)         else:
22)             subprocess.run(["git", "clone", "--depth=1",
23)                             TESTDATA_REPO,
24)                             tmp + "/freewvs-testdata"],
25)                            check=True)
26) 
Hanno Böck avoid some pylint warnings

Hanno Böck authored 4 years ago

27)         for tdir in glob.glob(tmp + "/freewvs-testdata/webapps/*"):
28)             bdir = os.path.basename(tdir)
29)             for tarball in glob.glob(tdir + "/dist/*"):
Hanno Böck add test with online testdata

Hanno Böck authored 4 years ago

30)                 shutil.unpack_archive(tarball, "%s/%s/%s-src"
31)                                       % (tmp, bdir, os.path.basename(tarball)))
32)             fwrun = subprocess.run(["./freewvs", "-a", tmp + "/" + bdir],
33)                                    stdout=subprocess.PIPE, check=True)
34)             fwdata = re.sub(tmp, "[dir]", fwrun.stdout.decode("utf-8"))
35)             fwclean = re.sub(r' \(.* ', " ", fwdata)
Hanno Böck avoid some pylint warnings

Hanno Böck authored 4 years ago

36)             f = open(tdir + "/refdata-a.txt")