-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.py
More file actions
57 lines (47 loc) · 1.7 KB
/
tests.py
File metadata and controls
57 lines (47 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import logging
import os
import re
import shutil
import unittest
from glob import glob
from pathlib import Path
from semantic_version import SimpleSpec
from github_release_downloader import check_and_download_updates, GitHubRepo
class DownloadRelease(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.repo = GitHubRepo("MBQbUtils", "BulkStartStop", os.environ.get("GITHUB_TOKEN", ""))
cls.spec = SimpleSpec("~1.0")
cls.out_dir = Path("test/out")
logging.basicConfig(
format="[%(asctime)s][%(levelname)s] %(message)s",
datefmt='%H:%M:%S',
level=logging.INFO
)
def tearDown(self):
shutil.rmtree(self.out_dir, True)
for path in glob("repo-*-*.cache"):
Path(path).unlink()
def test_download_compatible_exe(self):
check_and_download_updates(
self.repo,
self.spec,
assets_mask=re.compile(".*\\.exe"),
downloads_dir=self.out_dir
)
files = glob(str(self.out_dir.joinpath("*.exe")))
file_expected = Path(self.out_dir).joinpath("BulkStartStop_setup.exe")
file_actual = Path(files[0])
self.assertTrue(file_actual.samefile(file_expected))
def test_download_latest_zip(self):
check_and_download_updates(
self.repo,
assets_mask=re.compile(".*\\.zip"),
downloads_dir=self.out_dir
)
files = glob(str(self.out_dir.joinpath("*.zip")))
file_expected = Path(self.out_dir).joinpath("BulkStartStop_portable.zip")
file_actual = Path(files[0])
self.assertTrue(file_actual.samefile(file_expected))
if __name__ == '__main__':
unittest.main()