ciocore 5.1.1__py2.py3-none-any.whl → 10.0.0b3__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ciocore/VERSION +1 -1
- ciocore/__init__.py +23 -1
- ciocore/api_client.py +655 -160
- ciocore/auth/__init__.py +5 -3
- ciocore/cli.py +501 -0
- ciocore/common.py +15 -13
- ciocore/conductor_submit.py +77 -60
- ciocore/config.py +127 -13
- ciocore/data.py +162 -77
- ciocore/docsite/404.html +746 -0
- ciocore/docsite/apidoc/api_client/index.html +3605 -0
- ciocore/docsite/apidoc/apidoc/index.html +909 -0
- ciocore/docsite/apidoc/config/index.html +1652 -0
- ciocore/docsite/apidoc/data/index.html +1553 -0
- ciocore/docsite/apidoc/hardware_set/index.html +2460 -0
- ciocore/docsite/apidoc/package_environment/index.html +1507 -0
- ciocore/docsite/apidoc/package_tree/index.html +2386 -0
- ciocore/docsite/assets/_mkdocstrings.css +16 -0
- ciocore/docsite/assets/images/favicon.png +0 -0
- ciocore/docsite/assets/javascripts/bundle.471ce7a9.min.js +29 -0
- ciocore/docsite/assets/javascripts/bundle.471ce7a9.min.js.map +7 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.ar.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.da.min.js +18 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.de.min.js +18 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.du.min.js +18 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.el.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.es.min.js +18 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.fi.min.js +18 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.fr.min.js +18 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.he.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.hi.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.hu.min.js +18 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.hy.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.it.min.js +18 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.ja.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.jp.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.kn.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.ko.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.multi.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.nl.min.js +18 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.no.min.js +18 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.pt.min.js +18 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.ro.min.js +18 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.ru.min.js +18 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.sa.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.stemmer.support.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.sv.min.js +18 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.ta.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.te.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.th.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.tr.min.js +18 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.vi.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.zh.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/tinyseg.js +206 -0
- ciocore/docsite/assets/javascripts/lunr/wordcut.js +6708 -0
- ciocore/docsite/assets/javascripts/workers/search.b8dbb3d2.min.js +42 -0
- ciocore/docsite/assets/javascripts/workers/search.b8dbb3d2.min.js.map +7 -0
- ciocore/docsite/assets/stylesheets/main.3cba04c6.min.css +1 -0
- ciocore/docsite/assets/stylesheets/main.3cba04c6.min.css.map +1 -0
- ciocore/docsite/assets/stylesheets/palette.06af60db.min.css +1 -0
- ciocore/docsite/assets/stylesheets/palette.06af60db.min.css.map +1 -0
- ciocore/docsite/cmdline/docs/index.html +871 -0
- ciocore/docsite/cmdline/downloader/index.html +934 -0
- ciocore/docsite/cmdline/packages/index.html +878 -0
- ciocore/docsite/cmdline/uploader/index.html +995 -0
- ciocore/docsite/how-to-guides/index.html +869 -0
- ciocore/docsite/index.html +895 -0
- ciocore/docsite/logo.png +0 -0
- ciocore/docsite/objects.inv +0 -0
- ciocore/docsite/search/search_index.json +1 -0
- ciocore/docsite/sitemap.xml +3 -0
- ciocore/docsite/sitemap.xml.gz +0 -0
- ciocore/docsite/stylesheets/extra.css +26 -0
- ciocore/docsite/stylesheets/tables.css +167 -0
- ciocore/downloader/base_downloader.py +644 -0
- ciocore/downloader/download_runner_base.py +47 -0
- ciocore/downloader/job_downloader.py +119 -0
- ciocore/{downloader.py → downloader/legacy_downloader.py} +12 -9
- ciocore/downloader/log.py +73 -0
- ciocore/downloader/logging_download_runner.py +87 -0
- ciocore/downloader/perpetual_downloader.py +63 -0
- ciocore/downloader/registry.py +97 -0
- ciocore/downloader/reporter.py +135 -0
- ciocore/exceptions.py +8 -2
- ciocore/file_utils.py +51 -50
- ciocore/hardware_set.py +449 -0
- ciocore/loggeria.py +89 -20
- ciocore/package_environment.py +110 -48
- ciocore/package_query.py +182 -0
- ciocore/package_tree.py +319 -258
- ciocore/retry.py +0 -0
- ciocore/uploader/_uploader.py +547 -364
- ciocore/uploader/thread_queue_job.py +176 -0
- ciocore/uploader/upload_stats/__init__.py +3 -4
- ciocore/uploader/upload_stats/stats_formats.py +10 -4
- ciocore/validator.py +34 -2
- ciocore/worker.py +174 -151
- ciocore-10.0.0b3.dist-info/METADATA +928 -0
- ciocore-10.0.0b3.dist-info/RECORD +128 -0
- {ciocore-5.1.1.dist-info → ciocore-10.0.0b3.dist-info}/WHEEL +1 -1
- ciocore-10.0.0b3.dist-info/entry_points.txt +2 -0
- tests/instance_type_fixtures.py +175 -0
- tests/package_fixtures.py +205 -0
- tests/test_api_client.py +297 -12
- tests/test_base_downloader.py +104 -0
- tests/test_cli.py +149 -0
- tests/test_common.py +1 -7
- tests/test_config.py +40 -18
- tests/test_data.py +162 -173
- tests/test_downloader.py +118 -0
- tests/test_hardware_set.py +139 -0
- tests/test_job_downloader.py +213 -0
- tests/test_package_query.py +38 -0
- tests/test_package_tree.py +91 -291
- tests/test_submit.py +44 -18
- tests/test_uploader.py +1 -4
- ciocore/__about__.py +0 -10
- ciocore/cli/conductor.py +0 -191
- ciocore/compat.py +0 -15
- ciocore-5.1.1.data/scripts/conductor +0 -19
- ciocore-5.1.1.data/scripts/conductor.bat +0 -13
- ciocore-5.1.1.dist-info/METADATA +0 -408
- ciocore-5.1.1.dist-info/RECORD +0 -47
- tests/mocks/api_client_mock.py +0 -51
- /ciocore/{cli → downloader}/__init__.py +0 -0
- {ciocore-5.1.1.dist-info → ciocore-10.0.0b3.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
""" test data
|
|
2
|
+
|
|
3
|
+
isort:skip_file
|
|
4
|
+
"""
|
|
5
|
+
import unittest
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
from ciocore.hardware_set import HardwareSet
|
|
9
|
+
|
|
10
|
+
PROJECTS = [
|
|
11
|
+
"Deadpool",
|
|
12
|
+
"Harry Potter & the chamber of secrets",
|
|
13
|
+
"Captain Corelli's Mandolin",
|
|
14
|
+
"Gone with the Wind",
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
from package_fixtures import *
|
|
18
|
+
from instance_type_fixtures import (
|
|
19
|
+
CW_INSTANCE_TYPES,
|
|
20
|
+
AWS_INSTANCE_TYPES,
|
|
21
|
+
CW_INSTANCE_TYPES_WITH_GPUS,
|
|
22
|
+
ALL_INSTANCE_TYPES,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class TestCategorizedInstanceTypes(unittest.TestCase):
|
|
27
|
+
def setUp(self):
|
|
28
|
+
self.hs = HardwareSet(CW_INSTANCE_TYPES)
|
|
29
|
+
|
|
30
|
+
def test_number_of_categories(self):
|
|
31
|
+
self.assertEqual(self.hs.number_of_categories(), 4)
|
|
32
|
+
|
|
33
|
+
def test_categories_sorted_on_order(self):
|
|
34
|
+
labels = [i["label"] for i in self.hs.get_model()]
|
|
35
|
+
self.assertEqual(labels, ["low", "mid", "high", "extra"])
|
|
36
|
+
|
|
37
|
+
def test_content_count(self):
|
|
38
|
+
low_category_values = [c["value"] for c in self.hs.get_model()[0]["content"]]
|
|
39
|
+
self.assertEqual(low_category_values, ["cw-a-4-16", "cw-b-8-16"])
|
|
40
|
+
|
|
41
|
+
def test_in_several_categories(self):
|
|
42
|
+
low_category_values = [c["value"] for c in self.hs.get_model()[0]["content"]]
|
|
43
|
+
extra_category_values = [c["value"] for c in self.hs.get_model()[3]["content"]]
|
|
44
|
+
self.assertIn("cw-a-4-16", low_category_values)
|
|
45
|
+
self.assertIn("cw-a-4-16", extra_category_values)
|
|
46
|
+
|
|
47
|
+
def test_category_names(self):
|
|
48
|
+
names = self.hs.labels()
|
|
49
|
+
self.assertEqual(names, ["low", "mid", "high", "extra"])
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class TestRecategorizeInstanceTypes(unittest.TestCase):
|
|
53
|
+
def setUp(self):
|
|
54
|
+
self.hs = HardwareSet(CW_INSTANCE_TYPES_WITH_GPUS)
|
|
55
|
+
|
|
56
|
+
def test_recategorize_cpu_gpu(self):
|
|
57
|
+
test_func = (
|
|
58
|
+
lambda x: [{"label": "GPU", "order": 2}]
|
|
59
|
+
if "gpu" in x and x["gpu"]
|
|
60
|
+
else [{"label": "CPU", "order": 1}]
|
|
61
|
+
)
|
|
62
|
+
self.hs.recategorize(test_func)
|
|
63
|
+
self.assertEqual(self.hs.number_of_categories(), 2)
|
|
64
|
+
|
|
65
|
+
def test_find_all_by_condition(self):
|
|
66
|
+
test_func = lambda x: "gpu" in x and x["gpu"]
|
|
67
|
+
result = self.hs.find_all(test_func)
|
|
68
|
+
self.assertEqual(len(result), 2)
|
|
69
|
+
print(self.hs)
|
|
70
|
+
|
|
71
|
+
def test_find_first_by_condition(self):
|
|
72
|
+
test_func = lambda x: x["memory"] < 32
|
|
73
|
+
result = self.hs.find_first(test_func)
|
|
74
|
+
self.assertTrue(result["memory"] < 32)
|
|
75
|
+
|
|
76
|
+
def test_find_category(self):
|
|
77
|
+
label = "mid"
|
|
78
|
+
result = self.hs.find_category(label)
|
|
79
|
+
self.assertEqual(result["label"], label)
|
|
80
|
+
self.assertEqual(result["order"], 2)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class TestFind(unittest.TestCase):
|
|
84
|
+
def setUp(self):
|
|
85
|
+
self.hs = HardwareSet(CW_INSTANCE_TYPES_WITH_GPUS)
|
|
86
|
+
|
|
87
|
+
def test_find_unspecified_category(self):
|
|
88
|
+
result = self.hs.find("cw-e-4-32")
|
|
89
|
+
self.assertIsNotNone(result)
|
|
90
|
+
|
|
91
|
+
def test_category_that_exists(self):
|
|
92
|
+
result = self.hs.find("cw-e-4-32", category="high")
|
|
93
|
+
self.assertIsNotNone(result)
|
|
94
|
+
|
|
95
|
+
def test_returns_none_if_not_in_category(self):
|
|
96
|
+
result = self.hs.find("cw-e-4-32", category="low")
|
|
97
|
+
self.assertIsNone(result)
|
|
98
|
+
|
|
99
|
+
def test_returns_none_if_non_existent_category(self):
|
|
100
|
+
result = self.hs.find("cw-e-4-32", category="foo")
|
|
101
|
+
self.assertIsNone(result)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
class TestUncategorizedInstanceTypes(unittest.TestCase):
|
|
105
|
+
def setUp(self):
|
|
106
|
+
self.hs = HardwareSet(ALL_INSTANCE_TYPES)
|
|
107
|
+
|
|
108
|
+
def test_number_of_categories_uncategorized(self):
|
|
109
|
+
self.assertEqual(self.hs.number_of_categories(), 1)
|
|
110
|
+
|
|
111
|
+
def test_model_sorted_on_cores_mem(self):
|
|
112
|
+
content = self.hs.get_model()[0]["content"]
|
|
113
|
+
result = [c["label"] for c in content]
|
|
114
|
+
self.assertEqual(
|
|
115
|
+
result,
|
|
116
|
+
[
|
|
117
|
+
"windows 4 core 26.0GB Mem",
|
|
118
|
+
"linux 4 core 27.0GB Mem",
|
|
119
|
+
"linux 8 core 30.0GB Mem",
|
|
120
|
+
"windows 32 core 208.0GB Mem",
|
|
121
|
+
"linux 32 core 208.0GB Mem",
|
|
122
|
+
"windows 64 core 416.0GB Mem",
|
|
123
|
+
"linux 64 core 416.0GB Mem",
|
|
124
|
+
],
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class TestProvider(unittest.TestCase):
|
|
129
|
+
def test_gcp_provider(self):
|
|
130
|
+
hs = HardwareSet(ALL_INSTANCE_TYPES)
|
|
131
|
+
self.assertEqual(hs.provider, "gcp")
|
|
132
|
+
|
|
133
|
+
def test_cw_provider(self):
|
|
134
|
+
hs = HardwareSet(CW_INSTANCE_TYPES_WITH_GPUS)
|
|
135
|
+
self.assertEqual(hs.provider, "cw")
|
|
136
|
+
|
|
137
|
+
def test_aws_provider(self):
|
|
138
|
+
hs = HardwareSet(AWS_INSTANCE_TYPES)
|
|
139
|
+
self.assertEqual(hs.provider, "aws")
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
from ciocore.downloader.job_downloader import JobDownloader, flatten
|
|
2
|
+
import unittest
|
|
3
|
+
from unittest import mock
|
|
4
|
+
import re
|
|
5
|
+
import json
|
|
6
|
+
|
|
7
|
+
DOWNLOAD_BATCHES = {
|
|
8
|
+
"00000": [
|
|
9
|
+
{
|
|
10
|
+
"next_cursor": "00000_1",
|
|
11
|
+
"downloads": [
|
|
12
|
+
{
|
|
13
|
+
"download_id": 1,
|
|
14
|
+
"files": [
|
|
15
|
+
{"url": "https://example.com/file1", "size": 100},
|
|
16
|
+
{"url": "https://example.com/file2", "size": 200},
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"download_id": 2,
|
|
21
|
+
"files": [
|
|
22
|
+
{"url": "https://example.com/file3", "size": 100},
|
|
23
|
+
{"url": "https://example.com/file4", "size": 200},
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"next_cursor": "00000_2",
|
|
30
|
+
"downloads": [
|
|
31
|
+
{
|
|
32
|
+
"download_id": 3,
|
|
33
|
+
"files": [
|
|
34
|
+
{"url": "https://example.com/file5", "size": 100},
|
|
35
|
+
{"url": "https://example.com/file6", "size": 200},
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"download_id": 4,
|
|
40
|
+
"files": [
|
|
41
|
+
{"url": "https://example.com/file7", "size": 100},
|
|
42
|
+
{"url": "https://example.com/file8", "size": 200},
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"next_cursor": None,
|
|
49
|
+
"downloads": [
|
|
50
|
+
{
|
|
51
|
+
"download_id": 5,
|
|
52
|
+
"files": [
|
|
53
|
+
{"url": "https://example.com/file9", "size": 100},
|
|
54
|
+
{"url": "https://example.com/file10", "size": 200},
|
|
55
|
+
],
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
"00001": [
|
|
61
|
+
{
|
|
62
|
+
"next_cursor": "00001_1",
|
|
63
|
+
"downloads": [
|
|
64
|
+
{
|
|
65
|
+
"download_id": 101,
|
|
66
|
+
"files": [
|
|
67
|
+
{"url": "https://example.com/file101", "size": 100},
|
|
68
|
+
{"url": "https://example.com/file102", "size": 200},
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"download_id": 102,
|
|
73
|
+
"files": [
|
|
74
|
+
{"url": "https://example.com/file103", "size": 100},
|
|
75
|
+
{"url": "https://example.com/file104", "size": 200},
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"next_cursor": "00001_2",
|
|
82
|
+
"downloads": [
|
|
83
|
+
{
|
|
84
|
+
"download_id": 103,
|
|
85
|
+
"files": [
|
|
86
|
+
{"url": "https://example.com/file105", "size": 100},
|
|
87
|
+
{"url": "https://example.com/file106", "size": 200},
|
|
88
|
+
],
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"download_id": 104,
|
|
92
|
+
"files": [
|
|
93
|
+
{"url": "https://example.com/file107", "size": 100},
|
|
94
|
+
{"url": "https://example.com/file108", "size": 200},
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"next_cursor": None,
|
|
101
|
+
"downloads": [
|
|
102
|
+
{
|
|
103
|
+
"download_id": 105,
|
|
104
|
+
"files": [
|
|
105
|
+
{"url": "https://example.com/file109", "size": 100},
|
|
106
|
+
{"url": "https://example.com/file110", "size": 200},
|
|
107
|
+
],
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
class MockedApiClient:
|
|
115
|
+
def _get_batch(self, cursor):
|
|
116
|
+
if not cursor:
|
|
117
|
+
return json.dumps(DOWNLOAD_BATCHES["00000"][0])
|
|
118
|
+
|
|
119
|
+
job_id, index = cursor.split("_")
|
|
120
|
+
index = int(index)
|
|
121
|
+
batch = json.dumps(DOWNLOAD_BATCHES[job_id][index])
|
|
122
|
+
return batch
|
|
123
|
+
|
|
124
|
+
def make_request(self, url, verb="POST", params=None, data=None, use_api_key=True):
|
|
125
|
+
m = re.match("/jobs/(\d{5})/downloads", url)
|
|
126
|
+
if m:
|
|
127
|
+
job_id = m.group(1)
|
|
128
|
+
# This is a request for a download batch
|
|
129
|
+
if not job_id in DOWNLOAD_BATCHES:
|
|
130
|
+
print(f"Job {job_id} not found")
|
|
131
|
+
return None, 204
|
|
132
|
+
else:
|
|
133
|
+
print(f"Job {job_id} found")
|
|
134
|
+
|
|
135
|
+
cursor = params.get("start_cursor", None)
|
|
136
|
+
batch = self._get_batch(cursor)
|
|
137
|
+
return batch, 201
|
|
138
|
+
else:
|
|
139
|
+
# This is not a request for a download batch
|
|
140
|
+
raise NotImplementedError("This is not a request for a download batch")
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
class TestJobDownloader(unittest.TestCase):
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def setUp(self):
|
|
147
|
+
download_tasks_patcher = mock.patch.object(JobDownloader,"download_tasks")
|
|
148
|
+
self.mock_download_tasks = download_tasks_patcher.start()
|
|
149
|
+
self.addCleanup(download_tasks_patcher.stop)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def test_batch_all_batches(self):
|
|
153
|
+
mocked_jobs = DOWNLOAD_BATCHES.keys()
|
|
154
|
+
|
|
155
|
+
# instantiate
|
|
156
|
+
jdl = JobDownloader(mocked_jobs)
|
|
157
|
+
|
|
158
|
+
# set the mocked api client
|
|
159
|
+
jdl.client = MockedApiClient()
|
|
160
|
+
|
|
161
|
+
jdl.run()
|
|
162
|
+
self.assertEqual(self.mock_download_tasks.call_count, 6)
|
|
163
|
+
|
|
164
|
+
# def test_no_calls_if_non_existent_job(self):
|
|
165
|
+
# mocked_jobs = ["00002"]
|
|
166
|
+
# ``
|
|
167
|
+
# # instantiate
|
|
168
|
+
# jdl = JobDownloader(mocked_jobs)
|
|
169
|
+
|
|
170
|
+
# # set the mocked api client
|
|
171
|
+
# jdl.client = MockedApiClient()
|
|
172
|
+
|
|
173
|
+
# jdl.run()
|
|
174
|
+
# self.assertEqual(self.mock_download_tasks.call_count, 0)
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
# mock_get_some_tasks.side_effect = get_some_tasks_side_effect
|
|
178
|
+
|
|
179
|
+
# tasks, locator = jdl.get_some_tasks(None)
|
|
180
|
+
# self.assertEqual(tasks, ["t1,t2,t3"])
|
|
181
|
+
# self.assertEqual(locator, {"job_index": 0, "cursor": "a"})
|
|
182
|
+
|
|
183
|
+
# print(jdl.get_some_tasks(2))
|
|
184
|
+
# print(jdl.get_some_tasks(3))
|
|
185
|
+
|
|
186
|
+
# with mock.patch('requests.get') as mock_get:
|
|
187
|
+
# # Construct the expected JSON response
|
|
188
|
+
# json_response = {
|
|
189
|
+
# "next_cursor": "AA",
|
|
190
|
+
# "downloads": [
|
|
191
|
+
# {
|
|
192
|
+
# "download_id": 1,
|
|
193
|
+
# "files": [
|
|
194
|
+
# {
|
|
195
|
+
# "url": "https://example.com/file1",
|
|
196
|
+
# "size": 100
|
|
197
|
+
# },
|
|
198
|
+
# {
|
|
199
|
+
# "url": "https://example.com/file2",
|
|
200
|
+
# "size": 200
|
|
201
|
+
# }
|
|
202
|
+
# ]
|
|
203
|
+
# }
|
|
204
|
+
# ],
|
|
205
|
+
# "job_id": "00000",
|
|
206
|
+
# "output_dir": "/some/path",
|
|
207
|
+
# "size": 300,
|
|
208
|
+
# "task_id": "001"
|
|
209
|
+
# }
|
|
210
|
+
# # Create a mock response object
|
|
211
|
+
# mock_response = mock_get.return_value
|
|
212
|
+
# # Set the JSON content of the response
|
|
213
|
+
# mock_response.json.return_value = json_response
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
""" test package_query
|
|
2
|
+
"""
|
|
3
|
+
import unittest
|
|
4
|
+
import os
|
|
5
|
+
import sys
|
|
6
|
+
import copy
|
|
7
|
+
from ciocore import package_tree
|
|
8
|
+
from ciocore import package_query
|
|
9
|
+
from package_fixtures import *
|
|
10
|
+
|
|
11
|
+
class HostnameSortByVersionTest(unittest.TestCase):
|
|
12
|
+
def setUp(self):
|
|
13
|
+
self.packages = copy.deepcopy(SOFTWARE_DATA)
|
|
14
|
+
self.pt = package_tree.PackageTree(self.packages)
|
|
15
|
+
self.hostname_list = self.pt.supported_host_names()
|
|
16
|
+
|
|
17
|
+
def test_sort_hostnames_by_version(self):
|
|
18
|
+
sorted_hostnames = package_query.sort_hostnames_by_version(self.hostname_list)
|
|
19
|
+
sorted_data = {}
|
|
20
|
+
for item in sorted_hostnames:
|
|
21
|
+
product, version, platform = item.split()
|
|
22
|
+
data = {
|
|
23
|
+
'version': version,
|
|
24
|
+
'platform': platform
|
|
25
|
+
}
|
|
26
|
+
if product in sorted_data.keys():
|
|
27
|
+
sorted_data[product].append(data)
|
|
28
|
+
else:
|
|
29
|
+
sorted_data[product] = [data]
|
|
30
|
+
self.assertTrue(sorted(list(sorted_data.keys())) == list(sorted_data.keys()))
|
|
31
|
+
for product in sorted_data.keys():
|
|
32
|
+
platform_list = [pkg['platform'] for pkg in sorted_data[product]]
|
|
33
|
+
self.assertTrue(sorted(platform_list) == platform_list)
|
|
34
|
+
version_list = [pkg['version'] for pkg in sorted_data[product] if pkg['platform'] == 'linux']
|
|
35
|
+
self.assertTrue(sorted(version_list, reverse=True) == version_list)
|
|
36
|
+
|
|
37
|
+
if __name__ == "__main__":
|
|
38
|
+
unittest.main()
|