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.
Files changed (126) hide show
  1. ciocore/VERSION +1 -1
  2. ciocore/__init__.py +23 -1
  3. ciocore/api_client.py +655 -160
  4. ciocore/auth/__init__.py +5 -3
  5. ciocore/cli.py +501 -0
  6. ciocore/common.py +15 -13
  7. ciocore/conductor_submit.py +77 -60
  8. ciocore/config.py +127 -13
  9. ciocore/data.py +162 -77
  10. ciocore/docsite/404.html +746 -0
  11. ciocore/docsite/apidoc/api_client/index.html +3605 -0
  12. ciocore/docsite/apidoc/apidoc/index.html +909 -0
  13. ciocore/docsite/apidoc/config/index.html +1652 -0
  14. ciocore/docsite/apidoc/data/index.html +1553 -0
  15. ciocore/docsite/apidoc/hardware_set/index.html +2460 -0
  16. ciocore/docsite/apidoc/package_environment/index.html +1507 -0
  17. ciocore/docsite/apidoc/package_tree/index.html +2386 -0
  18. ciocore/docsite/assets/_mkdocstrings.css +16 -0
  19. ciocore/docsite/assets/images/favicon.png +0 -0
  20. ciocore/docsite/assets/javascripts/bundle.471ce7a9.min.js +29 -0
  21. ciocore/docsite/assets/javascripts/bundle.471ce7a9.min.js.map +7 -0
  22. ciocore/docsite/assets/javascripts/lunr/min/lunr.ar.min.js +1 -0
  23. ciocore/docsite/assets/javascripts/lunr/min/lunr.da.min.js +18 -0
  24. ciocore/docsite/assets/javascripts/lunr/min/lunr.de.min.js +18 -0
  25. ciocore/docsite/assets/javascripts/lunr/min/lunr.du.min.js +18 -0
  26. ciocore/docsite/assets/javascripts/lunr/min/lunr.el.min.js +1 -0
  27. ciocore/docsite/assets/javascripts/lunr/min/lunr.es.min.js +18 -0
  28. ciocore/docsite/assets/javascripts/lunr/min/lunr.fi.min.js +18 -0
  29. ciocore/docsite/assets/javascripts/lunr/min/lunr.fr.min.js +18 -0
  30. ciocore/docsite/assets/javascripts/lunr/min/lunr.he.min.js +1 -0
  31. ciocore/docsite/assets/javascripts/lunr/min/lunr.hi.min.js +1 -0
  32. ciocore/docsite/assets/javascripts/lunr/min/lunr.hu.min.js +18 -0
  33. ciocore/docsite/assets/javascripts/lunr/min/lunr.hy.min.js +1 -0
  34. ciocore/docsite/assets/javascripts/lunr/min/lunr.it.min.js +18 -0
  35. ciocore/docsite/assets/javascripts/lunr/min/lunr.ja.min.js +1 -0
  36. ciocore/docsite/assets/javascripts/lunr/min/lunr.jp.min.js +1 -0
  37. ciocore/docsite/assets/javascripts/lunr/min/lunr.kn.min.js +1 -0
  38. ciocore/docsite/assets/javascripts/lunr/min/lunr.ko.min.js +1 -0
  39. ciocore/docsite/assets/javascripts/lunr/min/lunr.multi.min.js +1 -0
  40. ciocore/docsite/assets/javascripts/lunr/min/lunr.nl.min.js +18 -0
  41. ciocore/docsite/assets/javascripts/lunr/min/lunr.no.min.js +18 -0
  42. ciocore/docsite/assets/javascripts/lunr/min/lunr.pt.min.js +18 -0
  43. ciocore/docsite/assets/javascripts/lunr/min/lunr.ro.min.js +18 -0
  44. ciocore/docsite/assets/javascripts/lunr/min/lunr.ru.min.js +18 -0
  45. ciocore/docsite/assets/javascripts/lunr/min/lunr.sa.min.js +1 -0
  46. ciocore/docsite/assets/javascripts/lunr/min/lunr.stemmer.support.min.js +1 -0
  47. ciocore/docsite/assets/javascripts/lunr/min/lunr.sv.min.js +18 -0
  48. ciocore/docsite/assets/javascripts/lunr/min/lunr.ta.min.js +1 -0
  49. ciocore/docsite/assets/javascripts/lunr/min/lunr.te.min.js +1 -0
  50. ciocore/docsite/assets/javascripts/lunr/min/lunr.th.min.js +1 -0
  51. ciocore/docsite/assets/javascripts/lunr/min/lunr.tr.min.js +18 -0
  52. ciocore/docsite/assets/javascripts/lunr/min/lunr.vi.min.js +1 -0
  53. ciocore/docsite/assets/javascripts/lunr/min/lunr.zh.min.js +1 -0
  54. ciocore/docsite/assets/javascripts/lunr/tinyseg.js +206 -0
  55. ciocore/docsite/assets/javascripts/lunr/wordcut.js +6708 -0
  56. ciocore/docsite/assets/javascripts/workers/search.b8dbb3d2.min.js +42 -0
  57. ciocore/docsite/assets/javascripts/workers/search.b8dbb3d2.min.js.map +7 -0
  58. ciocore/docsite/assets/stylesheets/main.3cba04c6.min.css +1 -0
  59. ciocore/docsite/assets/stylesheets/main.3cba04c6.min.css.map +1 -0
  60. ciocore/docsite/assets/stylesheets/palette.06af60db.min.css +1 -0
  61. ciocore/docsite/assets/stylesheets/palette.06af60db.min.css.map +1 -0
  62. ciocore/docsite/cmdline/docs/index.html +871 -0
  63. ciocore/docsite/cmdline/downloader/index.html +934 -0
  64. ciocore/docsite/cmdline/packages/index.html +878 -0
  65. ciocore/docsite/cmdline/uploader/index.html +995 -0
  66. ciocore/docsite/how-to-guides/index.html +869 -0
  67. ciocore/docsite/index.html +895 -0
  68. ciocore/docsite/logo.png +0 -0
  69. ciocore/docsite/objects.inv +0 -0
  70. ciocore/docsite/search/search_index.json +1 -0
  71. ciocore/docsite/sitemap.xml +3 -0
  72. ciocore/docsite/sitemap.xml.gz +0 -0
  73. ciocore/docsite/stylesheets/extra.css +26 -0
  74. ciocore/docsite/stylesheets/tables.css +167 -0
  75. ciocore/downloader/base_downloader.py +644 -0
  76. ciocore/downloader/download_runner_base.py +47 -0
  77. ciocore/downloader/job_downloader.py +119 -0
  78. ciocore/{downloader.py → downloader/legacy_downloader.py} +12 -9
  79. ciocore/downloader/log.py +73 -0
  80. ciocore/downloader/logging_download_runner.py +87 -0
  81. ciocore/downloader/perpetual_downloader.py +63 -0
  82. ciocore/downloader/registry.py +97 -0
  83. ciocore/downloader/reporter.py +135 -0
  84. ciocore/exceptions.py +8 -2
  85. ciocore/file_utils.py +51 -50
  86. ciocore/hardware_set.py +449 -0
  87. ciocore/loggeria.py +89 -20
  88. ciocore/package_environment.py +110 -48
  89. ciocore/package_query.py +182 -0
  90. ciocore/package_tree.py +319 -258
  91. ciocore/retry.py +0 -0
  92. ciocore/uploader/_uploader.py +547 -364
  93. ciocore/uploader/thread_queue_job.py +176 -0
  94. ciocore/uploader/upload_stats/__init__.py +3 -4
  95. ciocore/uploader/upload_stats/stats_formats.py +10 -4
  96. ciocore/validator.py +34 -2
  97. ciocore/worker.py +174 -151
  98. ciocore-10.0.0b3.dist-info/METADATA +928 -0
  99. ciocore-10.0.0b3.dist-info/RECORD +128 -0
  100. {ciocore-5.1.1.dist-info → ciocore-10.0.0b3.dist-info}/WHEEL +1 -1
  101. ciocore-10.0.0b3.dist-info/entry_points.txt +2 -0
  102. tests/instance_type_fixtures.py +175 -0
  103. tests/package_fixtures.py +205 -0
  104. tests/test_api_client.py +297 -12
  105. tests/test_base_downloader.py +104 -0
  106. tests/test_cli.py +149 -0
  107. tests/test_common.py +1 -7
  108. tests/test_config.py +40 -18
  109. tests/test_data.py +162 -173
  110. tests/test_downloader.py +118 -0
  111. tests/test_hardware_set.py +139 -0
  112. tests/test_job_downloader.py +213 -0
  113. tests/test_package_query.py +38 -0
  114. tests/test_package_tree.py +91 -291
  115. tests/test_submit.py +44 -18
  116. tests/test_uploader.py +1 -4
  117. ciocore/__about__.py +0 -10
  118. ciocore/cli/conductor.py +0 -191
  119. ciocore/compat.py +0 -15
  120. ciocore-5.1.1.data/scripts/conductor +0 -19
  121. ciocore-5.1.1.data/scripts/conductor.bat +0 -13
  122. ciocore-5.1.1.dist-info/METADATA +0 -408
  123. ciocore-5.1.1.dist-info/RECORD +0 -47
  124. tests/mocks/api_client_mock.py +0 -51
  125. /ciocore/{cli → downloader}/__init__.py +0 -0
  126. {ciocore-5.1.1.dist-info → ciocore-10.0.0b3.dist-info}/top_level.txt +0 -0
@@ -1,237 +1,113 @@
1
1
  """ test package_tree
2
-
3
- isort:skip_file
4
2
  """
5
- import json
3
+ import unittest
6
4
  import os
7
- import random
8
5
  import sys
9
- import unittest
10
-
6
+ import copy
11
7
  from ciocore import package_tree
12
-
13
- JSON_FILENAME = os.path.join(os.path.dirname(__file__) , "fixtures", "sw_packages.json")
14
- with open(JSON_FILENAME, 'r') as content:
15
- packages_json = json.load(content)["data"]
16
-
17
- SRC = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "src")
18
- if SRC not in sys.path:
19
- sys.path.insert(0, SRC)
20
-
21
-
22
- class RemoveUnreachableTest(unittest.TestCase):
23
-
24
- def test_single_valid_tree_unchanged(self):
25
- paths = ["a", "a/b", "a/b/c"]
26
- results = package_tree.remove_unreachable(paths)
27
- self.assertEqual(results, paths)
28
-
29
- def test_many_valid_trees_unchanged(self):
30
- paths = ["a", "a/b", "a/b/c", "b", "b/b", "b/b/c", "c", "c/b", "c/b/c"]
31
- results = package_tree.remove_unreachable(paths)
32
- self.assertEqual(results, paths)
33
-
34
- def test_single_invalid_tree_culled_leaf(self):
35
- paths = ["a", "a/b", "b/b/c"]
36
- results = package_tree.remove_unreachable(paths)
37
- self.assertEqual(results, ["a", "a/b"])
38
-
39
- def test_single_invalid_tree_culled_below(self):
40
- paths = ["a", "b/b", "a/b/c"]
41
- results = package_tree.remove_unreachable(paths)
42
- self.assertEqual(results, ["a"])
43
-
44
- def test_multiple_invalid_tree_culled(self):
45
- paths = ["a", "a/b", "a/b/c", "b", "b/b", "b/b/c", "d", "c/b", "c/b/c"]
46
- results = package_tree.remove_unreachable(paths)
47
- self.assertEqual(
48
- results, [
49
- "a", "a/b", "a/b/c", "b", "b/b", "b/b/c", "d"])
50
-
51
- def test_random_input_order(self):
52
- paths = ["a", "a/b", "a/b/c", "b", "b/b", "b/b/c", "d", "c/b", "c/b/c"]
53
- random.shuffle(paths)
54
- results = package_tree.remove_unreachable(paths)
55
- self.assertEqual(
56
- results, [
57
- "a", "a/b", "a/b/c", "b", "b/b", "b/b/c", "d"])
8
+ from package_fixtures import *
58
9
 
59
10
 
60
11
  class ToNameTest(unittest.TestCase):
61
12
 
62
- def test_major_only(self):
63
- pkg = {
64
- "product": "foo-bar",
65
- "major_version": "1",
66
- "minor_version": "",
67
- "release_version": "",
68
- "build_version": ""
69
- }
70
- expected = "foo-bar 1"
13
+ def setUp(self):
14
+ self.packages = copy.deepcopy(BLENDER_DATA)
15
+
16
+ def test_major(self):
17
+ pkg = self.packages[0]
18
+ expected = "blender 1 linux"
71
19
  self.assertEqual(package_tree.to_name(pkg), expected)
72
20
 
73
21
  def test_major_minor(self):
74
- pkg = {
75
- "product": "foo-bar",
76
- "major_version": "1",
77
- "minor_version": "3",
78
- "release_version": "",
79
- "build_version": ""
80
- }
81
- expected = "foo-bar 1.3"
22
+ pkg = self.packages[1]
23
+ expected = "blender 1.0 linux"
82
24
  self.assertEqual(package_tree.to_name(pkg), expected)
83
25
 
84
26
  def test_major_minor_release(self):
85
- pkg = {
86
- "product": "foo-bar",
87
- "major_version": "1",
88
- "minor_version": "3",
89
- "release_version": "62",
90
- "build_version": ""
91
- }
92
- expected = "foo-bar 1.3.62"
27
+ pkg = self.packages[2]
28
+ expected = "blender 1.0.2 linux"
93
29
  self.assertEqual(package_tree.to_name(pkg), expected)
94
30
 
95
31
  def test_major_minor_release_build(self):
96
- pkg = {
97
- "product": "foo-bar",
98
- "major_version": "1",
99
- "minor_version": "3",
100
- "release_version": "62",
101
- "build_version": "876"
102
- }
103
- expected = "foo-bar 1.3.62.876"
104
- self.assertEqual(package_tree.to_name(pkg), expected)
105
-
106
- def test_platform(self):
107
- pkg = {
108
- "product": "foo-bar",
109
- "major_version": "1",
110
- "minor_version": "",
111
- "release_version": "",
112
- "build_version": "",
113
- "platform": "windows"
114
- }
115
- expected = "foo-bar 1 windows"
32
+ pkg = self.packages[3]
33
+ expected = "blender 1.0.2.3 linux"
116
34
  self.assertEqual(package_tree.to_name(pkg), expected)
117
35
 
36
+ def test_bad_platform(self):
37
+ with self.assertRaises(KeyError):
38
+ pkg = self.packages[0]
39
+ pkg["platform"] = "bad"
40
+ package_tree.to_name(pkg)
118
41
 
119
42
  class SoftwareDataInitTest(unittest.TestCase):
43
+ def setUp(self):
44
+ """
45
+ Pad out with just enough fields to allow link_plugin_packages() to run.
46
+ """
47
+ self.packages = copy.deepcopy(SOFTWARE_DATA)
120
48
 
121
49
  def test_smoke(self):
122
50
  pt = package_tree.PackageTree([])
123
51
  self.assertIsInstance(pt, package_tree.PackageTree)
124
52
 
125
- def test_init_with_product(self):
126
- pt = package_tree.PackageTree(packages_json, product="houdini")
127
- self.assertEqual(len(pt.tree["children"]), 2)
128
- pt = package_tree.PackageTree(packages_json, product="maya-io")
129
- self.assertEqual(len(pt.tree["children"]), 9)
130
-
131
- def test_init_with_no_product(self):
132
- pt = package_tree.PackageTree(packages_json)
133
- self.assertEqual(len(pt.tree["children"]), 79)
134
-
135
- def test_init_with_sub_product(self):
136
- pt = package_tree.PackageTree(
137
- packages_json,
138
- product="arnold-houdini")
139
- self.assertEqual(len(pt.tree["children"]), 4)
140
-
141
- def test_init_with_windows_product(self):
142
- pt = package_tree.PackageTree(
143
- packages_json,
144
- product="cinema4d")
145
- self.assertEqual(len(pt.tree["children"]), 2)
146
-
147
- class SoftwareDataTestInitPlatformFilter(unittest.TestCase):
148
-
149
- def test_does_not_filter_by_default(self):
150
- pt = package_tree.PackageTree(packages_json, product="cinema4d")
151
- self.assertEqual(len(pt.tree["children"]), 2)
152
-
153
- def test_filter_windows(self):
154
- pt = package_tree.PackageTree(packages_json, product="cinema4d", platforms=["windows"])
155
- self.assertEqual(len(pt.tree["children"]), 1)
156
- self.assertEqual(pt.tree["children"][0]["platform"], "windows")
157
-
158
- def test_filter_linux(self):
159
- pt = package_tree.PackageTree(packages_json, product="cinema4d", platforms=["linux"])
160
- self.assertEqual(len(pt.tree["children"]), 1)
161
- self.assertEqual(pt.tree["children"][0]["platform"], "linux")
162
-
53
+ def test_init_with_filter_host_products(self):
54
+ pt = package_tree.PackageTree(self.packages, "maya", "blender")
55
+ self.assertEqual(len(pt.as_dict()["children"]), len(MAYA_DATA+BLENDER_DATA))
56
+
57
+ def test_init_with_one_product(self):
58
+ pt = package_tree.PackageTree(self.packages, product="redshift")
59
+ self.assertEqual(len(pt.as_dict()["children"]), len(REDSHIFT_DATA))
60
+
61
+ def test_init_with_all_product(self):
62
+ pt = package_tree.PackageTree(self.packages)
63
+ self.assertEqual(len(pt.as_dict()["children"]), len(HOST_DATA))
64
+
65
+ def test_filter_platform(self):
66
+ pt = package_tree.PackageTree(self.packages, platforms=["windows"])
67
+ expected = [h for h in HOST_DATA if h["platform"] == "windows"]
68
+ self.assertEqual( len(pt.as_dict()["children"]) , len(expected) )
69
+
70
+ def test_filter_platform_and_product(self):
71
+ pt = package_tree.PackageTree(self.packages, product="c4d", platforms=["linux"])
72
+ expected = [h for h in C4D_DATA if h["platform"] == "windows"]
73
+ self.assertEqual(len(pt._tree["children"]), len(expected))
74
+
163
75
  def test_raise_bad_platform(self):
164
76
  with self.assertRaises(KeyError):
165
- pt = package_tree.PackageTree(packages_json, product="cinema4d", platforms=["bad"])
166
-
77
+ pt = package_tree.PackageTree(self.packages, platforms=["bad"])
167
78
 
168
- class SoftwareDataFindByKeysTest(unittest.TestCase):
79
+ def test_nonexistent_product_falsy(self):
80
+ pt = package_tree.PackageTree(self.packages, product="noexist")
81
+ self.assertFalse(pt)
169
82
 
170
- def setUp(self):
171
- self.pt = package_tree.PackageTree(packages_json, product="houdini")
172
-
173
- def test_find_host_by_keys(self):
174
- keys = {
175
- 'product': 'houdini',
176
- 'major_version': '16',
177
- 'minor_version': '5',
178
- 'release_version': '323',
179
- 'build_version': '',
180
- 'plugin_host_product': '',
181
- 'plugin_host_version': ''
182
- }
183
- pkg = self.pt.find_by_keys(**keys)
184
- self.assertEqual(pkg["product"], 'houdini')
185
- self.assertEqual(pkg["major_version"], '16')
186
- self.assertEqual(pkg["minor_version"], '5')
187
- self.assertEqual(pkg["release_version"], '323')
188
-
189
- def test_find_leaf_by_keys(self):
190
- keys = {
191
- 'product': 'al-shaders',
192
- 'major_version': '1',
193
- 'minor_version': '1',
194
- 'release_version': '',
195
- 'build_version': '',
196
- 'plugin_host_product': '',
197
- 'plugin_host_version': ''
198
- }
199
- pkg = self.pt.find_by_keys(**keys)
200
- self.assertEqual(pkg["product"], 'al-shaders')
201
- self.assertEqual(pkg["major_version"], '1')
202
- self.assertEqual(pkg["minor_version"], '1')
203
-
204
- def test_find_nonexistent_package_returns_none(self):
205
- keys = {
206
- 'product': 'arnold-houdini',
207
- 'major_version': '7',
208
- 'minor_version': '1',
209
- 'release_version': '',
210
- 'build_version': '',
211
- 'plugin_host_product': '',
212
- 'plugin_host_version': ''
213
- }
214
- pkg = self.pt.find_by_keys(**keys)
215
- self.assertEqual(pkg, None)
83
+ def test_good_product_truthy(self):
84
+ pt = package_tree.PackageTree(self.packages, product="redshift")
85
+ self.assertTrue(pt)
216
86
 
87
+ def test_as_dict_returns_underlying_tree(self):
88
+ pt = package_tree.PackageTree(self.packages)
89
+ self.assertEqual(pt.as_dict(), pt._tree)
90
+ self.assertIsInstance(pt.as_dict(), dict)
217
91
 
218
- class SoftwareDataFindByPathTest(unittest.TestCase):
219
92
 
220
- def setUp(self):
221
- self.pt = package_tree.PackageTree(packages_json, product="houdini")
93
+ class SoftwareDataFindersTest(unittest.TestCase):
222
94
 
95
+ def setUp(self):
96
+ self.packages = copy.deepcopy(SOFTWARE_DATA)
97
+ self.pt = package_tree.PackageTree(self.packages, product="maya")
98
+
223
99
  def test_find_root_path(self):
224
- path = "houdini 16.0.736 linux"
100
+ path = "maya 1.1 linux"
225
101
  pkg = self.pt.find_by_path(path)
226
102
  self.assertEqual(package_tree.to_name(pkg), path)
227
103
 
228
104
  def test_find_leaf_path(self):
229
- path = "houdini 16.0.736 linux/arnold-houdini 2.0.2.2 linux/al-shaders 1.0 linux"
105
+ path = "maya 1.1 linux/redshift 1 linux"
230
106
  pkg = self.pt.find_by_path(path)
231
- self.assertEqual(package_tree.to_name(pkg), "al-shaders 1.0 linux")
107
+ self.assertEqual(package_tree.to_name(pkg), "redshift 1 linux")
232
108
 
233
109
  def test_find_nonexistent_path_return_none(self):
234
- path = "houdini 16.0.736 linux/arnold-houdini 9.0.2.2 linux"
110
+ path = "maya 1.1 linux/redshift 3 linux"
235
111
  pkg = self.pt.find_by_path(path)
236
112
  self.assertEqual(pkg, None)
237
113
 
@@ -240,149 +116,73 @@ class SoftwareDataFindByPathTest(unittest.TestCase):
240
116
  pkg = self.pt.find_by_path(path)
241
117
  self.assertEqual(pkg, None)
242
118
 
243
- def test_find_none_path_return_none(self):
244
- path = None
245
- pkg = self.pt.find_by_path(path)
246
- self.assertEqual(pkg, None)
247
-
248
- class FindByNameTest(unittest.TestCase):
249
- def setUp(self):
250
- self.pt = package_tree.PackageTree(packages_json, product="houdini")
251
-
252
119
  def test_find_root(self):
253
- name = 'houdini 16.5.323 linux'
120
+ name = 'maya 1.1 linux'
254
121
  result = self.pt.find_by_name(name)
255
122
  self.assertEqual(package_tree.to_name(result), name)
256
123
 
257
124
  def test_find_root_when_limit_1(self):
258
- name = 'houdini 16.5.323 linux'
125
+ name = 'maya 1.1 linux'
259
126
  result = self.pt.find_by_name(name, 1)
260
127
  self.assertEqual(package_tree.to_name(result), name)
261
128
 
262
129
  def test_find_plugin_level(self):
263
- name = "arnold-houdini 2.0.2.2 linux"
130
+ name = "redshift 1 linux"
264
131
  result = self.pt.find_by_name(name)
265
132
  self.assertEqual(package_tree.to_name(result), name)
266
133
 
267
- def test_find_plugin_level_high_limit(self):
268
- name = "arnold-houdini 2.0.2.2 linux"
269
- result = self.pt.find_by_name(name, 2)
270
- self.assertEqual(package_tree.to_name(result), name)
271
-
272
134
  def test_dont_find_plugin_level_when_limited(self):
273
- name = "arnold-houdini 2.0.2.2 linux"
135
+ name = "redshift 1 linux"
274
136
  result = self.pt.find_by_name(name, 1)
275
137
  self.assertEqual(result, None)
276
138
 
277
-
278
- class SoftwareDataGetAllPathsTest(unittest.TestCase):
279
-
280
- def setUp(self):
281
- self.pt = package_tree.PackageTree(packages_json, product="houdini")
282
-
283
- def test_get_all_paths_to_root(self):
284
-
285
- keys = {
286
- 'product': 'houdini',
287
- 'major_version': '16',
288
- 'minor_version': '5',
289
- 'release_version': '323',
290
- 'build_version': '',
291
- 'plugin_host_product': '',
292
- 'plugin_host_version': '',
293
- 'platform': 'linux',
294
-
295
- }
296
- paths = self.pt.get_all_paths_to(**keys)
297
- self.assertTrue(
298
- 'houdini 16.5.323 linux' in paths)
299
- self.assertEqual(len(paths), 1)
300
-
301
- def test_get_all_paths_to_leaf(self):
302
-
303
- keys = {
304
- 'product': 'al-shaders',
305
- 'major_version': '1',
306
- 'minor_version': '0',
307
- 'release_version': '',
308
- 'build_version': '',
309
- 'plugin_host_product': '',
310
- 'plugin_host_version': '',
311
- "platform": "linux"
312
- }
313
- paths = self.pt.get_all_paths_to(**keys)
314
- self.assertTrue(
315
- 'houdini 16.0.736 linux/arnold-houdini 2.0.1 linux/al-shaders 1.0 linux' in paths)
316
- self.assertEqual(len(paths), 2)
317
-
318
- def test_get_all_paths_to_nonexistent(self):
319
-
320
- keys = {
321
- 'product': 'foo',
322
- 'major_version': '1',
323
- 'minor_version': '0',
324
- 'release_version': '',
325
- 'build_version': '',
326
- 'plugin_host_product': '',
327
- 'plugin_host_version': '',
328
- "platform": "linux"
329
- }
330
- paths = self.pt.get_all_paths_to(**keys)
331
- self.assertEqual(paths, [])
332
-
333
-
334
139
  class SoftwarePlatformsSetTest(unittest.TestCase):
335
140
  # There are Windows packages in c4d but not Maya.
141
+ def setUp(self):
142
+ self.packages = copy.deepcopy(SOFTWARE_DATA)
143
+
336
144
  def test_only_linux(self):
337
- pt = package_tree.PackageTree(packages_json, product="maya-io")
145
+ pt = package_tree.PackageTree(self.packages, product="maya")
338
146
  self.assertEqual({"linux"}, pt.platforms())
339
-
147
+
340
148
  def test_linux_and_windows(self):
341
- pt = package_tree.PackageTree(packages_json, product="cinema4d")
149
+ pt = package_tree.PackageTree(self.packages, product="c4d")
342
150
  self.assertEqual({"windows", "linux"}, pt.platforms())
343
-
151
+
344
152
 
345
153
  class SupportedHostNamesTest(unittest.TestCase):
346
154
  def setUp(self):
347
- self.pt = package_tree.PackageTree(packages_json, product="maya-io")
348
- self.one_hostname = 'maya-io 2018.SP2 linux'
155
+ self.packages = copy.deepcopy(SOFTWARE_DATA)
349
156
 
350
157
  def test_supported_host_names(self):
351
-
158
+ self.pt = package_tree.PackageTree(self.packages, product="maya")
352
159
  host_names = self.pt.supported_host_names()
353
-
354
- self.assertEqual(len(host_names), 9)
355
- self.assertIn(self.one_hostname, host_names)
160
+ self.assertEqual(len(host_names), 3)
161
+ self.assertIn('maya 1.1 linux', host_names)
356
162
 
357
163
  def test_supported_host_names_windows(self):
358
- self.pt = package_tree.PackageTree(packages_json, product="cinema4d")
164
+ self.pt = package_tree.PackageTree(self.packages, product="c4d", platforms=["windows"])
359
165
  host_names = self.pt.supported_host_names()
360
166
  self.assertEqual(len(host_names), 2)
361
- self.assertIn('cinema4d 25.117.RB316423 windows', host_names)
167
+ self.assertIn('c4d 1.0 windows', host_names)
362
168
 
363
169
 
364
170
  class SupportedPluginsTest(unittest.TestCase):
365
171
  def setUp(self):
366
- self.pt = package_tree.PackageTree(packages_json, product="maya-io")
367
- self.one_hostname = 'maya-io 2018.SP2 linux'
368
-
369
- def test_supported_plugins_count(self):
370
- plugins = self.pt.supported_plugins(self.one_hostname)
371
- self.assertEqual(len(plugins), 4)
172
+ self.packages = copy.deepcopy(SOFTWARE_DATA)
173
+ self.pt = package_tree.PackageTree(self.packages, product="maya")
174
+ self.one_hostname = 'maya 1.0 linux'
372
175
 
373
-
374
176
  def test_supported_plugins_keys(self):
375
177
  plugins = self.pt.supported_plugins(self.one_hostname)
376
178
  self.assertIsInstance(plugins[0], dict)
377
179
  self.assertIn("plugin",plugins[0])
378
180
  self.assertIn("versions",plugins[0])
379
181
 
380
- def test_supported_plugins_version_count(self):
182
+ def test_supported_plugins_and_versions_count(self):
381
183
  plugins = self.pt.supported_plugins(self.one_hostname)
382
- self.assertEqual(len(plugins[0]["versions"]), 8)
383
-
384
- # TODO Test PackageTree#get_environment()
385
-
184
+ self.assertEqual(len(plugins), 1)
185
+ self.assertEqual(plugins[0]["versions"], ["1", "2"])
386
186
 
387
- if __name__ == '__main__':
187
+ if __name__ == "__main__":
388
188
  unittest.main()
tests/test_submit.py CHANGED
@@ -4,8 +4,9 @@
4
4
  """
5
5
 
6
6
  import unittest
7
- from mock import patch
8
- from mock import MagicMock
7
+
8
+ from unittest.mock import MagicMock, patch
9
+
9
10
 
10
11
  def get_required_args():
11
12
  return {
@@ -23,7 +24,9 @@ class InitTest(unittest.TestCase):
23
24
  self.kSubmit = Submit
24
25
  self.required_args = get_required_args()
25
26
 
26
- getuser_patcher = patch("getpass.getuser", return_value="joe.bloggs@example.com")
27
+ getuser_patcher = patch(
28
+ "getpass.getuser", return_value="joe.bloggs@example.com"
29
+ )
27
30
  self.mock_getuser = getuser_patcher.start()
28
31
  self.addCleanup(getuser_patcher.stop)
29
32
 
@@ -65,42 +68,48 @@ class SendTest(unittest.TestCase):
65
68
  self.kSubmit = Submit
66
69
  self.required_args = get_required_args()
67
70
 
68
- getuser_patcher = patch("getpass.getuser", return_value="joe.bloggs@example.com")
71
+ getuser_patcher = patch(
72
+ "getpass.getuser", return_value="joe.bloggs@example.com"
73
+ )
69
74
  self.mock_getuser = getuser_patcher.start()
70
75
  self.addCleanup(getuser_patcher.stop)
71
76
 
72
77
  file_utils_process_patcher = patch(
73
- "ciocore.file_utils.process_upload_filepaths",
74
- return_value=[]
78
+ "ciocore.file_utils.process_upload_filepaths", return_value=[]
75
79
  )
76
80
  self.mock_file_utils_process = file_utils_process_patcher.start()
77
81
  self.addCleanup(file_utils_process_patcher.stop)
78
82
 
79
83
  make_request_patcher = patch(
80
84
  "ciocore.api_client.ApiClient.make_request",
81
- return_value=('{}', 201),
85
+ return_value=("{}", 201),
82
86
  )
83
87
  self.mock_make_request = make_request_patcher.start()
84
88
  self.addCleanup(make_request_patcher.stop)
85
89
 
86
-
87
- def test_send_calls_handle_local_upload_by_default(self):
90
+ def test_send_calls_handle_local_upload_by_default_when_upload_paths_present(self):
88
91
  args = self.required_args
92
+ args["upload_paths"] = ["/a/b"]
93
+
89
94
  submission = self.kSubmit(args)
90
95
  submission._handle_local_upload = MagicMock()
91
96
  submission.main()
92
97
  submission._handle_local_upload.assert_called_with({})
93
98
 
94
-
95
- def test_send_calls_enforce_md5s_if_local_upload_off_and_enforced_md5s(self):
96
- args = {"local_upload": False, "enforced_md5s": {"a":"1"}}
99
+ def test_send_calls_enforce_md5s_if_local_upload_off_and_enforced_md5s_when_upload_paths_present(
100
+ self,
101
+ ):
102
+ args = {"local_upload": False, "enforced_md5s": {"a": "1"}}
103
+ args["upload_paths"] = ["/a/b"]
97
104
  args.update(self.required_args)
98
105
  submission = self.kSubmit(args)
99
106
  submission._enforce_md5s = MagicMock()
100
107
  submission.main()
101
108
  submission._enforce_md5s.assert_called_with({})
102
109
 
103
- def test_send_doesnt_call_enforce_md5s_if_local_upload_off_and_no_enforced_md5s(self):
110
+ def test_send_doesnt_call_enforce_md5s_if_local_upload_off_and_no_enforced_md5s(
111
+ self,
112
+ ):
104
113
  args = {"local_upload": False}
105
114
  args.update(self.required_args)
106
115
  submission = self.kSubmit(args)
@@ -108,14 +117,30 @@ class SendTest(unittest.TestCase):
108
117
  submission.main()
109
118
  self.assertEqual(submission._enforce_md5s.call_count, 0)
110
119
 
120
+ def test_send_doesnt_call_any_upload_methods_if_no_upload_paths(self):
121
+ args = self.required_args
122
+ submission = self.kSubmit(args)
123
+ submission._handle_local_upload = MagicMock()
124
+ submission._enforce_md5s = MagicMock()
125
+ submission.main()
126
+ self.assertEqual(submission._handle_local_upload.call_count, 0)
127
+ self.assertEqual(submission._enforce_md5s.call_count, 0)
128
+
129
+ def test_send_switches_local_upload_true_if_no_upload_paths_and_local_upload_false(
130
+ self,
131
+ ):
132
+ args = {"local_upload": False}
133
+ args.update(self.required_args)
134
+ submission = self.kSubmit(args)
135
+ self.assertEqual(submission.payload["local_upload"], True)
111
136
 
112
137
  def test_send_raise_if_bad_response_code(self):
113
138
  make_request_patcher = patch(
114
139
  "ciocore.api_client.ApiClient.make_request",
115
- return_value=('{}', 404),
140
+ return_value=("{}", 404),
116
141
  )
117
142
  self.mock_make_request = make_request_patcher.start()
118
-
143
+
119
144
  with self.assertRaises(Exception):
120
145
  submission = self.kSubmit(self.required_args)
121
146
  submission._handle_daemon_upload = MagicMock()
@@ -124,11 +149,12 @@ class SendTest(unittest.TestCase):
124
149
  make_request_patcher.stop()
125
150
 
126
151
 
127
- class uploaderTest():
152
+ class uploaderTest:
128
153
 
129
154
  def test_smoke(self):
130
155
 
131
156
  from ciocore import uploader
157
+
132
158
  uploader_args = {
133
159
  "location": "here",
134
160
  "database_filepath": "/path/to/db",
@@ -137,5 +163,5 @@ class uploaderTest():
137
163
  }
138
164
  up = uploader.Uploader(uploader_args)
139
165
  manager = up.create_manager("some_project")
140
- filemap = {"/a/b1": None,"/a/b2": None}
141
- self.assertTrue(True)
166
+ filemap = {"/a/b1": None, "/a/b2": None}
167
+ # self.assertEqual(uploader_args["thread_count"], 4)
tests/test_uploader.py CHANGED
@@ -1,10 +1,7 @@
1
1
  import unittest
2
2
  import sys
3
3
 
4
- try:
5
- from unittest import mock
6
- except ImportError:
7
- import mock
4
+ from unittest import mock
8
5
 
9
6
  PY3 = sys.version_info >= (3, 0)
10
7
  BUILTIN_OPEN = "builtins.open" if PY3 else "__builtin__.open"
ciocore/__about__.py DELETED
@@ -1,10 +0,0 @@
1
- import os
2
-
3
- __all__ = ["__version__"]
4
-
5
- try:
6
- with open(os.path.join(os.path.abspath(os.path.dirname(__file__)), 'VERSION')) as version_file:
7
- __version__ = version_file.read().strip()
8
-
9
- except IOError:
10
- __version__ = 'dev'