Coverage for venv / lib / python3.12 / site-packages / combinatrix / test / fixtures / settings_bundle.py: 0%
48 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-05-05 00:09 +0100
« prev ^ index » next coverage.py v7.13.5, created at 2026-05-05 00:09 +0100
1import os, shutil
2from combinatrix.testintegration import rel2abs
5class SettingsBundleFactory(object):
7 @classmethod
8 def make_bundle(cls, settings_csv, settings_json, matrix, modified_order):
9 fixtures = rel2abs(__file__, "..", "resources", "fixtures")
10 bundle = rel2abs(__file__, "..", "resources", "fixtures", "test_bundle")
12 bundle_info = {
13 "settings_csv": {
14 "path": None,
15 "mtime": -1,
16 "status": settings_csv
17 },
18 "settings_json": {
19 "path": None,
20 "mtime": -1,
21 "status": settings_json
22 },
23 "matrix": {
24 "path": None,
25 "mtime": -1,
26 "status": matrix
27 }
28 }
30 target = os.path.join(bundle, "test_bundle.settings.csv")
31 bundle_info["settings_csv"]["path"] = target
32 if settings_csv in ["present"] and "settings_csv" in modified_order:
33 source = os.path.join(fixtures, "test_bundle.settings.csv")
34 shutil.copy(source, target)
35 offset = modified_order.index("settings_csv")
36 mtime = (offset + 1) * 1000
37 os.utime(target, (mtime, mtime))
38 bundle_info["settings_csv"]["mtime"] = mtime
40 target = os.path.join(bundle, "test_bundle.settings.json")
41 bundle_info["settings_json"]["path"] = target
42 if settings_json in ["present"] and "settings_json" in modified_order:
43 source = os.path.join(fixtures, "test_bundle.settings.json")
44 shutil.copy(source, target)
45 offset = modified_order.index("settings_json")
46 mtime = (offset + 1) * 1000
47 os.utime(target, (mtime, mtime))
48 bundle_info["settings_json"]["mtime"] = mtime
50 target = os.path.join(bundle, "test_bundle.matrix.csv")
51 bundle_info["matrix"]["path"] = target
52 if matrix in ["present"] and "matrix" in modified_order:
53 source = os.path.join(fixtures, "test_bundle.matrix.csv")
54 shutil.copy(source, target)
55 offset = modified_order.index("matrix")
56 mtime = (offset + 1) * 1000
57 os.utime(target, (mtime, mtime))
58 bundle_info["matrix"]["mtime"] = mtime
60 return bundle_info
62 @classmethod
63 def tear_down_bundle(cls):
64 bundle = rel2abs(__file__, "..", "resources", "fixtures", "test_bundle")
65 settings_csv = os.path.join(bundle, "test_bundle.settings.csv")
66 settings_json = os.path.join(bundle, "test_bundle.settings.json")
67 matrix = os.path.join(bundle, "test_bundle.matrix.csv")
69 if os.path.exists(settings_csv):
70 os.remove(settings_csv)
71 if os.path.exists(settings_json):
72 os.remove(settings_json)
73 if os.path.exists(matrix):
74 os.remove(matrix)