ciocore 8.3.1__py2.py3-none-any.whl → 8.3.3__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.

Potentially problematic release.


This version of ciocore might be problematic. Click here for more details.

Binary file
ciocore/package_query.py CHANGED
@@ -120,14 +120,25 @@ def write_text(hostnames, tree_data, platform, color_func, stream):
120
120
  ),
121
121
  stream,
122
122
  )
123
-
123
+
124
+ def sort_hostnames_by_version(hostnames):
125
+ def sort_version(pkg):
126
+ hostname, product, version, platform = pkg
127
+ return f"{version} {product} {platform}"
128
+ def sort_product(pkg):
129
+ hostname, product, version, platform = pkg
130
+ return f"{product} {platform}"
131
+ pkg_sortable = [(hostname, hostname.split()[0], hostname.split()[1], hostname.split()[2]) for hostname in hostnames]
132
+ _psorted = sorted(pkg_sortable, key=sort_version, reverse=True)
133
+ _sorted = sorted(_psorted, key=sort_product)
134
+ return [pkg[0] for pkg in _sorted]
124
135
 
125
136
  def pq(format="text"):
126
137
  packages = api_client.request_software_packages()
127
138
 
128
139
  tree_data = PackageTree(packages)
129
140
 
130
- hostnames = tree_data.supported_host_names()
141
+ hostnames = sort_hostnames_by_version(tree_data.supported_host_names())
131
142
  linux_hostnames = [h for h in hostnames if h.endswith("linux")]
132
143
  windows_hostnames = [h for h in hostnames if h.endswith("windows")]
133
144
 
@@ -168,4 +179,4 @@ def pq(format="text"):
168
179
  def decorate(html):
169
180
  html = html.replace("<table>", '<table class="pure-table pure-table-bordered">')
170
181
  html = '<html><head>{}</head><body style="margin: 2em;">{}</body></html>'.format(PURE, html)
171
- return html
182
+ return html
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ciocore
3
- Version: 8.3.1
3
+ Version: 8.3.3
4
4
  Summary: Core functionality for Conductor's client tools
5
5
  Home-page: https://github.com/ConductorTechnologies/ciocore
6
6
  Author: conductor
@@ -9,13 +9,13 @@ Classifier: Operating System :: OS Independent
9
9
  Classifier: Programming Language :: Python
10
10
  Classifier: Topic :: Multimedia :: Graphics :: 3D Rendering
11
11
  Description-Content-Type: text/markdown
12
- Requires-Dist: requests[use_chardet_on_py3] ==2.28.1
13
- Requires-Dist: pyjwt ==1.7.1
14
- Requires-Dist: future >=0.18.2
15
- Requires-Dist: cioseq <1.0.0,>=0.4.1
16
- Requires-Dist: Click <9.0.0,>=8.1.3
17
- Requires-Dist: markdown <4.0.0,>=3.5.2
18
- Requires-Dist: colorlog <7.0.0,>=6.8.2
12
+ Requires-Dist: requests[use_chardet_on_py3]==2.28.1
13
+ Requires-Dist: pyjwt==1.7.1
14
+ Requires-Dist: future>=0.18.2
15
+ Requires-Dist: cioseq<1.0.0,>=0.4.1
16
+ Requires-Dist: Click<9.0.0,>=8.1.3
17
+ Requires-Dist: markdown<4.0.0,>=3.5.2
18
+ Requires-Dist: colorlog<7.0.0,>=6.8.2
19
19
 
20
20
  ## Introduction
21
21
 
@@ -51,6 +51,14 @@ See [CONTRIBUTING](CONTRIBUTING.md)
51
51
 
52
52
  ## Changelog
53
53
 
54
+ ## Version:8.3.3 -- 04 Dec 2024
55
+
56
+ * Adds filter option for API data query
57
+
58
+ ## Version:8.3.2 -- 01 Oct 2024
59
+
60
+ * Tweak to package order behavior for markdown package query
61
+
54
62
  ## Version:8.3.1 -- 05 Sep 2024
55
63
 
56
64
  * Fixes a bug of the Conductor log going to the wrong path on Windows
@@ -1,19 +1,19 @@
1
- ciocore/VERSION,sha256=rmeFKlQ4QGAI5SKqVg8znd1CZl1ozCVgtxHLoIKwdLs,5
1
+ ciocore/VERSION,sha256=CPW4ywaMrQJwqnxuD6QhQjZADphOtNGh1wwcjUpgMj4,5
2
2
  ciocore/__init__.py,sha256=aTP7LeeosQA8BZE67gDV4jgfTK5zxmwZRjiTRu_ZWj0,646
3
- ciocore/api_client.py,sha256=SBxEwAiwn2XtH7T_ipefUbWhczXjoNdNbQBur1RV-Bw,32810
3
+ ciocore/api_client.py,sha256=IZXP5QHUAQvoiQEexr4lHdysHXNoDbTrxmBdgczVRwU,33009
4
4
  ciocore/cli.py,sha256=jZ1lOKQiUcrMhsVmD9SVmPMFwHtgDF4SaoAf2-PBS54,15449
5
5
  ciocore/client_db.py,sha256=tTz3bl2xeDPPcYSDS3g3QgV_xYihJMx0Kj6OeN2klK0,12978
6
6
  ciocore/common.py,sha256=mBIS6KiYoQsjWe6aIFUGRRvCMl8BIN2kmLZ4J8icap8,14982
7
7
  ciocore/compat.py,sha256=5uEXPSog_jxsDMaHBswAKEtfyXT25VgU6WNGIhz9PHU,256
8
8
  ciocore/conductor_submit.py,sha256=bxvzdyNzscAOOOsqTvAYh5DQsTWyCQJNb16Mf-n_F0M,9702
9
9
  ciocore/config.py,sha256=rCL7kaFn1tYgSglN8q9Wx6SwMpoXTq0BMQGwPRVwVIg,8973
10
- ciocore/data.py,sha256=Ji0qUk8nJXBNakoHSqBiVx8O58SbZXyt273SHlEDn3U,7027
10
+ ciocore/data.py,sha256=zT3zpkSbHPHHGlLeLDTbwkB8_-Ct6zd8qQ-7U1pDCHM,7215
11
11
  ciocore/exceptions.py,sha256=4Oq-WX-qiN6kPUdBCHvvd6mtSQ0nCkDbJxWt2CNtpv8,1504
12
12
  ciocore/file_utils.py,sha256=swA7th9WhDEloW69YViRTKB-oeC9UmNdEGegfH1r-Gw,17176
13
13
  ciocore/hardware_set.py,sha256=FlRQiGCLRcSW7Oko_gzgVK8ZqJ_J92eT8e_AleAbS2E,17047
14
14
  ciocore/loggeria.py,sha256=dk8n899TYFiMTD2gjjj8oiumJkPtCus0a_IY2GORAvU,15251
15
15
  ciocore/package_environment.py,sha256=MEHV7jfs3NJIEYCIaW8JfJdBmelvPHZMmBzPlXETiRo,7808
16
- ciocore/package_query.py,sha256=2m5EBXfu1lmqupZrFF8f8mfkX_PgijpdMxCtFI5e5s0,5574
16
+ ciocore/package_query.py,sha256=hWi_JmRieZ8f2Ji5JR7tQnHnm29Ktb88scbIXNsDu-8,6181
17
17
  ciocore/package_tree.py,sha256=vkORKXxQ7dO8l0_96eFwm-5AUVL0rP9bhgWYhW_v3lo,15649
18
18
  ciocore/post_install.py,sha256=zu5Ctz2ANbKD-f5G2ODLIhKkWENBi4F3UKKu50OEWrg,1000
19
19
  ciocore/retry.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -26,11 +26,11 @@ ciocore/docsite/index.html,sha256=NEK4HaX2yaetTajVtQuTmS9C5cPnkAtxgeKEj7wQ9t0,20
26
26
  ciocore/docsite/logo.png,sha256=gArgFFWdw8w985-0TkuGIgU_pW9sziEMZdqytXb5WLo,2825
27
27
  ciocore/docsite/objects.inv,sha256=XwmLactPEWWC4fAWqHNPBXGsluRxLLTrwDLQqq51ONY,775
28
28
  ciocore/docsite/sitemap.xml,sha256=M_V85zl0y2adRvzJAnoCxlZH_Hl7TLnIb1A-6l_xGmI,109
29
- ciocore/docsite/sitemap.xml.gz,sha256=2xVWLq_KVIQN6qI9Vw76TGTPhAz5eEkcQP1Pl6YvAN4,127
30
- ciocore/docsite/apidoc/api_client/index.html,sha256=TvoSl4iqdXhBVfesDxe_sBPA6G-Jt1-gpWA40xXspa0,188372
29
+ ciocore/docsite/sitemap.xml.gz,sha256=Qw_9G64RFm0KsUtO6gBNfO91KGMJoHgSyOx4KMLMtRU,127
30
+ ciocore/docsite/apidoc/api_client/index.html,sha256=ECM-KQ5E-KRb1ZWvY1PGG2pjVDnK1m-Gmkkk5-vlVyE,189219
31
31
  ciocore/docsite/apidoc/apidoc/index.html,sha256=GOSvv6KZPOtgekgshRE4j7aDvJkkaiBQLwA_By9J94g,26171
32
32
  ciocore/docsite/apidoc/config/index.html,sha256=WDqy4MLR3EMp9T_2-Z9Op61rTFkvb0aTWmtjiR8sbjA,72559
33
- ciocore/docsite/apidoc/data/index.html,sha256=vjC5u7wcm2ryOW28GctA9ZG6dXgBTkMJLLomJ9Kqxo0,50850
33
+ ciocore/docsite/apidoc/data/index.html,sha256=8ldmfisgelzdWtTqGY8uebvVRcskhbv-reO3hMcIgGI,51627
34
34
  ciocore/docsite/apidoc/hardware_set/index.html,sha256=SpYg-lwuCvfLPbNIIM7aQL2jGt-NA5wlVMlIKixGwBo,123042
35
35
  ciocore/docsite/apidoc/package_environment/index.html,sha256=V6_ah3V1_4_aOwJbEcITCdwuHxe1vGtfn0maRrbflUs,69248
36
36
  ciocore/docsite/apidoc/package_tree/index.html,sha256=60Ir6X1Q9k17bQCqozXzuMAcSVuu6DuC5zGfBk4LLnw,109393
@@ -81,7 +81,7 @@ ciocore/docsite/cmdline/downloader/index.html,sha256=nygj-0GQmpD79B5AxHjwzQxOFv8
81
81
  ciocore/docsite/cmdline/packages/index.html,sha256=_kXB85PBAgrqW09OerYpxnJuyERHMbcLn6qBGRdyHwk,20923
82
82
  ciocore/docsite/cmdline/uploader/index.html,sha256=vuQ06Gys9Eoxs87PXlqnM5AgB6Ag00BlDIy6oaprjis,25123
83
83
  ciocore/docsite/how-to-guides/index.html,sha256=KifCHl2S3RfPBZhP1UXwUNWuhcXPlPPqM4Gk6rVGhjQ,20100
84
- ciocore/docsite/search/search_index.json,sha256=vBLU-rkC0pxOPX0O3MNKXRKGfgsaS1-91KsV17Gf9SY,189092
84
+ ciocore/docsite/search/search_index.json,sha256=ju5KaOoSD824cFvn8uEpJ_kTHJBJKyYtfC9k3ubuY-A,189844
85
85
  ciocore/docsite/stylesheets/extra.css,sha256=_Cxe9Dhg1BBi6Kqaz_iZD9z9VyqxA9vtONRjP4PVic0,354
86
86
  ciocore/docsite/stylesheets/tables.css,sha256=LE_zwGRxGcdPIy-9QiVPecOzlEBSqZb_WP5vDkFE0ZM,3235
87
87
  ciocore/downloader/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -99,29 +99,28 @@ ciocore/uploader/_uploader.py,sha256=40nzqO5DuFi4sx31VvjWxZPNkrWsWqM9jtFVxs_-o3o
99
99
  ciocore/uploader/upload_stats/__init__.py,sha256=Lg1y4zq1i0cwc6Hh2K1TAQDYymLff49W-uIo1xjcvdI,5309
100
100
  ciocore/uploader/upload_stats/stats_formats.py,sha256=giNirtObU66VALWghPFSRhg3q_vw5MvESsnXhb_I3y8,2402
101
101
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
102
- tests/extra_env_fixtures.py,sha256=8qvU4d8SXGKzRVNR5whVqKCQOwOVMiFVfbKBAjxa2gE,1119
103
102
  tests/instance_type_fixtures.py,sha256=uIzQduqKQVgjllMuyXaYnRC-pwqk5lnTx3NY2M5Nujo,4320
104
- tests/package_fixtures.py,sha256=CsJnhB7oYzIxJH7b1tCOPyvnnVSCqEbSPhtCnsHL-nA,5070
105
- tests/project_fixtures.py,sha256=iBm_th_JtAw76vlNu7Jjhh9tLH4oOaNi-MgtPzCV7yQ,138
103
+ tests/package_fixtures.py,sha256=od7ZHofG8ubpQ3PqlUsrcHBcbmD3qVWih9eiIg1WtSQ,5361
106
104
  tests/test_api_client.py,sha256=4jhj-YrBPcLj7XZn3ngguau2DPxpCYGMSuqPJ3hW0GQ,14497
107
105
  tests/test_base_downloader.py,sha256=SS7tWKv2ZZhpUDk4UCg1TkrNrpntjSewgzLl1mEubSE,3603
108
106
  tests/test_cli.py,sha256=_WTs2SWlEgd6wtg1hmOBlFnbWVdFLvqp0KqNhy-y2e8,5532
109
107
  tests/test_common.py,sha256=tY_-SY-JmJX09UehFs9RIDqZ785AmhfTl6eVKJeIUFY,763
110
108
  tests/test_config.py,sha256=-_G682Ss3Zr1FmcMkjla1zAZprX2tQKpKc5_wD28rII,13340
111
- tests/test_data.py,sha256=NIBXpCjG3Os3vpc1CkiVONrebro8D_jqQyJ0N3kbucU,5433
109
+ tests/test_data.py,sha256=JGl_OsechVMJGpIgq6s86UnvNexAlwwjxW8HR6L3OEM,7625
112
110
  tests/test_downloader.py,sha256=hceljsjnuvk5Vk5X4mHgavIEcpbv8ylPwpz7rTwJ-aE,4721
113
111
  tests/test_hardware_set.py,sha256=hW7A_suyYdU7WkB7qoHSBPLxaAP2CKqI0i_ULfO5GeY,4408
114
112
  tests/test_imports_2and3.py,sha256=ehqpRYPVY7djBcb8OT_cnh86iCJJ9wuMWnfSR9RHxmY,507
115
113
  tests/test_job_downloader.py,sha256=_dZqyLZhc2Bq2n7-skERfodHx1JgFyHw8TamHp6ID9I,7025
116
114
  tests/test_package_environment.py,sha256=CdiC2PDVSnbcwTb4fsDTWqGYSzs1n5ca2KMoyISckGA,5893
117
- tests/test_package_tree.py,sha256=xCwNwYUmJrfmgCP2FGoHRFG-L0JPy8s4-66icxAls4o,6780
115
+ tests/test_package_query.py,sha256=LZqvCrGkWs0lMtIMumjDatX0ypeYYvabh_k1R0A6sS0,1451
116
+ tests/test_package_tree.py,sha256=K2kzJwRHCr6ojc4MZHjdH7VtmvG5O97OoH6vzwAE9GQ,6780
118
117
  tests/test_submit.py,sha256=ppijBcpLXeHUZh7UXyClxLalSV6cTfKb6Ygw5zXQPKo,5836
119
118
  tests/test_uploader.py,sha256=B1llTJt_fqR6e_V_Jxfw9z73QgkFlEPU87xLYGzt-TQ,2914
120
119
  tests/test_validator.py,sha256=2fY66ayNc08PGyj2vTI-V_1yeCWJDngkj2zkUM5TTCI,1526
121
120
  tests/mocks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
122
121
  tests/mocks/glob.py,sha256=J2MH7nqi6NJOHuGdVWxhfeBd700_Ckj6cLh_8jSNkfg,215
123
- ciocore-8.3.1.dist-info/METADATA,sha256=NNnft8rjUsxme5_1tZ4q72inZQAY6vIHxB60ZgHnvYo,18772
124
- ciocore-8.3.1.dist-info/WHEEL,sha256=DZajD4pwLWue70CAfc7YaxT1wLUciNBvN_TTcvXpltE,110
125
- ciocore-8.3.1.dist-info/entry_points.txt,sha256=cCqcALMYbC4d8545V9w0Zysfg9MVuKWhzDQ2er4UfGE,47
126
- ciocore-8.3.1.dist-info/top_level.txt,sha256=SvlM5JlqULzAz00JZWfiUhfjhqDzYzSWssA87zdJl0o,14
127
- ciocore-8.3.1.dist-info/RECORD,,
122
+ ciocore-8.3.3.dist-info/METADATA,sha256=gzm8TpBrMp-5IiLCxn_NCu8Qgn-1n1HMKHks7Cuh0l4,18934
123
+ ciocore-8.3.3.dist-info/WHEEL,sha256=qUzzGenXXuJTzyjFah76kDVqDvnk-YDzY00svnrl84w,109
124
+ ciocore-8.3.3.dist-info/entry_points.txt,sha256=cCqcALMYbC4d8545V9w0Zysfg9MVuKWhzDQ2er4UfGE,47
125
+ ciocore-8.3.3.dist-info/top_level.txt,sha256=SvlM5JlqULzAz00JZWfiUhfjhqDzYzSWssA87zdJl0o,14
126
+ ciocore-8.3.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (74.1.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py2-none-any
5
5
  Tag: py3-none-any
tests/package_fixtures.py CHANGED
@@ -139,12 +139,25 @@ C4D_DATA = [
139
139
  "minor_version": "0",
140
140
  "package_id": "id_9",
141
141
  },
142
+ {
143
+ "product": "c4d",
144
+ "major_version": "1",
145
+ "minor_version": "1",
146
+ "package_id": "id_10",
147
+ },
142
148
  {
143
149
  "product": "c4d",
144
150
  "platform": "windows",
145
151
  "major_version": "1",
146
152
  "minor_version": "0",
147
- "package_id": "id_10",
153
+ "package_id": "id_11",
154
+ },
155
+ {
156
+ "product": "c4d",
157
+ "platform": "windows",
158
+ "major_version": "1",
159
+ "minor_version": "1",
160
+ "package_id": "id_12",
148
161
  },
149
162
  ]
150
163
 
@@ -152,20 +165,20 @@ BLENDER_DATA = [
152
165
  {
153
166
  "product": "blender",
154
167
  "major_version": "1",
155
- "package_id": "id_11",
168
+ "package_id": "id_13",
156
169
  },
157
170
  {
158
171
  "product": "blender",
159
172
  "major_version": "1",
160
173
  "minor_version": "0",
161
- "package_id": "id_12",
174
+ "package_id": "id_14",
162
175
  },
163
176
  {
164
177
  "product": "blender",
165
178
  "major_version": "1",
166
179
  "minor_version": "0",
167
180
  "release_version": "2",
168
- "package_id": "id_13",
181
+ "package_id": "id_15",
169
182
  },
170
183
  {
171
184
  "product": "blender",
@@ -173,7 +186,7 @@ BLENDER_DATA = [
173
186
  "minor_version": "0",
174
187
  "release_version": "2",
175
188
  "build_version": "3",
176
- "package_id": "id_14",
189
+ "package_id": "id_16",
177
190
  },
178
191
  ]
179
192
 
tests/test_data.py CHANGED
@@ -1,163 +1,173 @@
1
- """ test data
2
-
3
- isort:skip_file
4
- """
5
-
6
1
  import unittest
2
+ from unittest.mock import patch, MagicMock
3
+ from ciocore import data as coredata
7
4
 
8
- try:
9
- from unittest import mock
10
- except ImportError:
11
- import mock
12
-
13
- from ciocore import data
14
-
15
-
16
- from project_fixtures import PROJECTS
17
- from package_fixtures import SOFTWARE_DATA
18
- from instance_type_fixtures import LIN_INSTANCE_TYPES, ALL_INSTANCE_TYPES
19
-
20
- class TestDataAllInstanceTypes(unittest.TestCase):
5
+ class TestCoreData(unittest.TestCase):
21
6
  def setUp(self):
22
- self.default_cache = {
23
- "projects": PROJECTS,
24
- "instance_types": ALL_INSTANCE_TYPES,
25
- "packages": SOFTWARE_DATA,
7
+ """Set up test fixtures before each test method."""
8
+ self.mock_api_responses = {
9
+ 'projects': ['ProjectA', 'ProjectB'],
10
+ 'instance_types': [
11
+ {'operating_system': 'windows', 'name': 'win_machine', 'cores': 1, 'memory': '1024'},
12
+ {'operating_system': 'linux', 'name': 'linux_machine', 'cores': 1, 'memory': '1024'}
13
+ ],
14
+ 'software': [ # Added package_id to each package
15
+ {
16
+ 'name': 'maya-io',
17
+ 'version': '2022',
18
+ 'platform': 'windows',
19
+ 'product': 'maya-io',
20
+ 'package_id': '123456789'
21
+ },
22
+ {
23
+ 'name': 'maya-io',
24
+ 'version': '2022',
25
+ 'platform': 'linux',
26
+ 'product': 'maya-io',
27
+ 'package_id': '123456780'
28
+ },
29
+ {
30
+ 'name': 'nuke',
31
+ 'version': '13.0',
32
+ 'platform': 'linux',
33
+ 'product': 'nuke',
34
+ 'package_id': '123456781'
35
+ }
36
+ ],
37
+ 'extra_env': ['PATH=/custom/path', 'LICENSE_SERVER=1234']
26
38
  }
27
-
28
- # self.get_data_patcher = mock.patch.object(DataCache, "get_data", return_value=self.default_cache)
29
-
30
- # self.account_id_patcher = mock.patch(
31
- # "ciocore.data.get_account_id", return_value="1234"
32
- # )
33
-
34
- # self.mock_get_data = self.get_data_patcher.start()
35
- # self.mock_account_id = self.account_id_patcher.start()
36
-
37
- data.__data__ = {}
38
- data.__products__ = None
39
+ # Clear data before each test
40
+ coredata.clear()
39
41
 
40
42
  def tearDown(self):
41
- # self.get_data_patcher.stop()
42
- # self.account_id_patcher.stop()
43
- pass
44
-
45
- # def override_default_cache(self, **kwargs):
46
- # return_val = {}
47
- # return_val.update(self.default_cache)
48
- # return_val.update(kwargs)
49
- # self.mock_get_data.return_value = return_val
50
-
51
- # def test_smoke(self):
52
- # self.assertEqual(1, 1)
53
-
54
- # def test_init_empty_projects_global(self):
55
- # data.init()
56
- # self.assertEqual(data.products(), [])
57
-
58
- # def test_init_stores_all_args(self):
59
- # data.init("a", "b", "c")
60
- # self.assertEqual(data.products(), ["a", "b", "c"])
61
-
62
- # def test_data_raises_if_not_initialized(self):
63
- # with self.assertRaises(ValueError):
64
- # data.data()
65
-
66
- # def test_valid(self):
67
- # self.assertEqual(data.valid(), False)
68
- # data.init()
69
- # data.data()
70
- # self.assertEqual(data.valid(), True)
71
-
72
- # def test_clear(self):
73
- # data.init()
74
- # data.data()
75
- # self.assertEqual(data.valid(), True)
76
- # data.clear()
77
- # self.assertEqual(data.valid(), False)
78
-
79
- # def test_does_not_refresh_if_not_force(self):
80
- # data.init()
81
- # p1 = data.data()["projects"]
82
- # self.assertEqual(len(p1), 4)
83
- # # merge the default cache with a new projects list containing only two projects
84
- # # self.override_default_cache(projects=["a", "b"])
85
- # p2 = data.data()["projects"]
86
- # self.assertEqual(p2, p1)
87
-
88
- # def test_does_refresh_if_force_all(self):
89
- # data.init()
90
- # p1 = data.data()["projects"]
91
- # self.assertEqual(len(p1), 4)
92
- # # self.override_default_cache(projects=["a", "b"])
93
- # p2 = data.data(force=True)["projects"]
94
- # self.assertNotEqual(p2, p1)
95
- # self.assertEqual(len(p2), 2)
96
-
97
- # def test_get_data_for_one_product(self):
98
- # data.init("c4d")
99
- # # inst = data.data()["instance_types"]
100
- # sw = data.data()["software"]
101
- # self.assertEqual(len(sw.supported_host_names()), 2)
102
-
103
- # def test_several_products(self):
104
- # data.init("c4d", "maya")
105
- # sw = data.data()["software"]
106
- # self.assertEqual(len(sw.supported_host_names()), 5)
107
-
108
- # def test_one_product_can_be_a_plugin(self):
109
- # data.init("redshift")
110
- # sw = data.data()["software"]
111
- # self.assertEqual(len(sw.supported_host_names()), 4)
112
-
113
- # def test_several_products_ignore_plugins(self):
114
- # data.init("redshift", "c4d")
115
- # sw = data.data()["software"]
116
- # self.assertEqual(len(sw.supported_host_names()), 2)
117
-
118
- # def test_linux_only_instance_types(self):
119
- # # self.override_default_cache(instance_types=LIN_INSTANCE_TYPES)
120
- # data.init()
121
- # h = data.data()["instance_types"]
122
- # self.assertEqual(len(h.instance_types.keys()), 4)
123
-
124
- # def test_linux_only_packages_when_linux_only_instance_types(self):
125
- # # self.override_default_cache(instance_types=LIN_INSTANCE_TYPES)
126
- # data.init("c4d")
127
- # sw = data.data()["software"]
128
- # self.assertEqual(len(sw.supported_host_names()), 1)
129
-
130
- # def test_platforms_method_only_linux(self):
131
- # self.override_default_cache(instance_types=LIN_INSTANCE_TYPES)/
132
- # data.init("c4d")
133
- # data.data()
134
- # self.assertEqual({"linux"}, data.platforms())
135
-
136
- # def test_many_products(self):
137
- # self.override_default_cache(instance_types=LIN_INSTANCE_TYPES)
138
- # data.init("c4d", "maya")
139
- # sw = data.data()["software"]
140
- # self.assertEqual(len(sw.supported_host_names()), 4)
141
-
142
- # def test_product_keyword_translates_to_single_arg(self):
143
- # data.init(product="c4d")
144
- # sw = data.data()["software"]
145
- # self.assertEqual(len(sw.supported_host_names()), 2)
146
-
147
- # def test_product_keyword_all_translates_to_all_products(self):
148
- # data.init(product="all")
149
- # sw = data.data()["software"]
150
- # self.assertEqual(len(sw.supported_host_names()), 11)
151
-
152
- # def test_data_raises_if_both_products_and_kwarg_given(self):
153
- # with self.assertRaises(ValueError):
154
- # data.init("maya", product="c4d")
155
-
156
- # def test_data_raises_if_products_and_kwarg_given(self):
157
- # with self.assertRaises(ValueError):
158
- # data.init("maya", product="c4d")
159
-
160
- class TestDataSmoke(unittest.TestCase):
161
-
162
- def test_smoke(self):
163
- self.assertTrue(True)
43
+ """Clean up after each test method."""
44
+ coredata.clear()
45
+
46
+ def test_init_with_single_product(self):
47
+ """Test initializing with a single product"""
48
+ coredata.init("maya-io")
49
+ self.assertEqual(coredata.products(), ["maya-io"])
50
+ self.assertEqual(coredata.platforms(), set(["windows", "linux"]))
51
+
52
+ def test_init_with_multiple_products(self):
53
+ """Test initializing with multiple products"""
54
+ coredata.init("maya-io", "nuke")
55
+ self.assertEqual(coredata.products(), ["maya-io", "nuke"])
56
+
57
+ def test_init_with_deprecated_product(self):
58
+ """Test initializing with deprecated product kwarg"""
59
+ coredata.init(product="maya-io")
60
+ self.assertEqual(coredata.products(), ["maya-io"])
61
+
62
+ def test_init_with_all_products(self):
63
+ """Test initializing with 'all' products"""
64
+ coredata.init(product="all")
65
+ self.assertEqual(coredata.products(), [])
66
+
67
+ def test_init_conflict_raises_error(self):
68
+ """Test that using both products arg and product kwarg raises error"""
69
+ with self.assertRaises(ValueError):
70
+ coredata.init("maya-io", product="nuke")
71
+
72
+ def test_data_requires_init(self):
73
+ """Test that data() raises error if not initialized"""
74
+ with self.assertRaises(ValueError):
75
+ coredata.data()
76
+
77
+ @patch('ciocore.data.api_client')
78
+ def test_data_fetching(self, mock_client):
79
+ """Test fetching data through the data() function"""
80
+ # Setup mock responses
81
+ mock_client.request_projects.return_value = self.mock_api_responses['projects']
82
+ mock_client.request_instance_types.return_value = self.mock_api_responses['instance_types']
83
+ mock_client.request_software_packages.return_value = self.mock_api_responses['software']
84
+ mock_client.request_extra_environment.return_value = self.mock_api_responses['extra_env']
85
+
86
+ coredata.init("maya-io")
87
+ result = coredata.data()
88
+
89
+ self.assertIn("projects", result)
90
+ self.assertIn("instance_types", result)
91
+ self.assertIn("software", result)
92
+ self.assertIn("extra_environment", result)
93
+
94
+ self.assertEqual(result["projects"], self.mock_api_responses["projects"])
95
+ self.assertIsInstance(result["instance_types"], coredata.HardwareSet)
96
+ self.assertIsInstance(result["software"], coredata.PackageTree)
97
+
98
+ @patch('ciocore.data.api_client')
99
+ def test_force_refresh(self, mock_client):
100
+ """Test forcing data refresh"""
101
+ # Setup mock responses
102
+ mock_client.request_projects.return_value = self.mock_api_responses['projects']
103
+ mock_client.request_instance_types.return_value = self.mock_api_responses['instance_types']
104
+ mock_client.request_software_packages.return_value = self.mock_api_responses['software']
105
+ mock_client.request_extra_environment.return_value = self.mock_api_responses['extra_env']
106
+
107
+ coredata.init("maya-io")
108
+ first_data = coredata.data()
109
+
110
+ # Second call without force should not make new API calls
111
+ mock_client.request_projects.reset_mock()
112
+ second_data = coredata.data()
113
+ mock_client.request_projects.assert_not_called()
114
+
115
+ # Call with force=True should make new API calls
116
+ third_data = coredata.data(force=True)
117
+ mock_client.request_projects.assert_called_once()
118
+
119
+ def test_valid_state(self):
120
+ """Test valid() function behavior"""
121
+ self.assertFalse(coredata.valid()) # Should be invalid before initialization
122
+
123
+ coredata.init("maya-io")
124
+ self.assertFalse(coredata.valid()) # Should be invalid before data is fetched
125
+
126
+ with patch('ciocore.data.api_client') as mock_client:
127
+ # Setup mock responses
128
+ mock_client.request_projects.return_value = self.mock_api_responses['projects']
129
+ mock_client.request_instance_types.return_value = self.mock_api_responses['instance_types']
130
+ mock_client.request_software_packages.return_value = self.mock_api_responses['software']
131
+ mock_client.request_extra_environment.return_value = self.mock_api_responses['extra_env']
132
+
133
+ coredata.data() # Fetch data
134
+ self.assertTrue(coredata.valid()) # Should be valid after data is fetched
135
+
136
+ coredata.clear()
137
+ self.assertFalse(coredata.valid()) # Should be invalid after clear
138
+
139
+ @patch('ciocore.data.api_client')
140
+ def test_platforms_filtering(self, mock_client):
141
+ """Test platform filtering based on instance types and software"""
142
+ # Setup mock responses
143
+ mock_client.request_projects.return_value = self.mock_api_responses['projects']
144
+ mock_client.request_instance_types.return_value = self.mock_api_responses['instance_types']
145
+ mock_client.request_software_packages.return_value = self.mock_api_responses['software']
146
+ mock_client.request_extra_environment.return_value = self.mock_api_responses['extra_env']
147
+
148
+ coredata.init("nuke") # nuke only supports linux
149
+ coredata.data()
150
+
151
+ # Should only have linux instance types since nuke only supports linux
152
+ self.assertEqual(coredata.platforms(), {"linux"})
153
+
154
+ @patch('ciocore.data.api_client')
155
+ def test_instances_filter(self, mock_client):
156
+ """Testing that instance_types is passed correctly to api_client"""
157
+ # Set up mock response
158
+ mock_client.request_instance_types.return_value = self.mock_api_responses['instance_types']
159
+ coredata.init("maya-io")
160
+
161
+ # Test with no filter
162
+ coredata.data()
163
+ mock_client.request_instance_types.assert_called_with(filter_param="")
164
+
165
+ # Test with filter and force=True
166
+ mock_client.request_instance_types.reset_mock()
167
+
168
+ instances_filter = "gpu.gpu_count=gte:1:int"
169
+ coredata.data(force=True, instances_filter=instances_filter)
170
+ mock_client.request_instance_types.assert_called_with(filter_param=instances_filter)
171
+
172
+ if __name__ == '__main__':
173
+ unittest.main()
@@ -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()
@@ -163,7 +163,7 @@ class SupportedHostNamesTest(unittest.TestCase):
163
163
  def test_supported_host_names_windows(self):
164
164
  self.pt = package_tree.PackageTree(self.packages, product="c4d", platforms=["windows"])
165
165
  host_names = self.pt.supported_host_names()
166
- self.assertEqual(len(host_names), 1)
166
+ self.assertEqual(len(host_names), 2)
167
167
  self.assertIn('c4d 1.0 windows', host_names)
168
168
 
169
169