Skip to content

Commit abad460

Browse files
SG-30702 Skip SG-MIM entities (#285)
* Skip MIM entities * Apply black formatter * Add notes and clean-up
1 parent 091821f commit abad460

3 files changed

Lines changed: 61 additions & 32 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ tests/config
2525
.cache
2626
.travis-solo
2727
htmlcov
28+
test-output.xml
2829

2930
# setup related
3031
build

azure-pipelines-templates/run-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ jobs:
5656
# Specifies which version of Python we want to use. That's where the strategy comes in.
5757
# Each job will share this set of steps, but each of them will receive a different
5858
# $(python.version)
59+
# TODO: We should provide `githubToken` if we want to download a python release.
60+
# Otherwise we may hit the GitHub anonymous download limit.
5961
- task: UsePythonVersion@0
6062
inputs:
6163
versionSpec: '$(python.version)'

tests/test_api_long.py

Lines changed: 58 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222

2323
class TestShotgunApiLong(base.LiveTestBase):
24-
2524
def test_automated_find(self):
2625
"""Called find for each entity type and read all fields"""
2726

@@ -35,8 +34,16 @@ def test_automated_find(self):
3534
limit = 1
3635
page = 1
3736
for entity_type in all_entities:
38-
if entity_type in ("Asset", "Task", "Shot", "Attachment",
39-
"Candidate"):
37+
if entity_type in (
38+
"Asset",
39+
"Task",
40+
"Shot",
41+
"Attachment",
42+
"Candidate",
43+
"MimProject",
44+
"MimEntity",
45+
"MimField",
46+
):
4047
continue
4148
print("Finding entity type %s" % entity_type)
4249

@@ -54,21 +61,27 @@ def test_automated_find(self):
5461
# Since no_sorting is not exposed to us, we'll have to rely on
5562
# this as a safeguard against trying to sort by a field with
5663
# allow_sorting=false.
57-
if field['data_type']["value"] in sortable_types:
64+
if field["data_type"]["value"] in sortable_types:
5865
order_field = field_name
5966
break
6067
# TODO for our test project, we haven't populated these entities....
6168
order = None
6269
if order_field:
63-
order = [{'field_name': order_field, 'direction': direction}]
70+
order = [{"field_name": order_field, "direction": direction}]
6471
if "project" in fields:
65-
filters = [['project', 'is', self.project]]
72+
filters = [["project", "is", self.project]]
6673
else:
6774
filters = []
6875

69-
records = self.sg.find(entity_type, filters, fields=list(fields.keys()),
70-
order=order, filter_operator=filter_operator,
71-
limit=limit, page=page)
76+
records = self.sg.find(
77+
entity_type,
78+
filters,
79+
fields=list(fields.keys()),
80+
order=order,
81+
filter_operator=filter_operator,
82+
limit=limit,
83+
page=page,
84+
)
7285

7386
self.assertTrue(isinstance(records, list))
7487

@@ -117,13 +130,12 @@ def test_schema(self):
117130
human_field_name = "Monkey " + str(random.getrandbits(24))
118131

119132
properties = {"description": "How many monkeys were needed"}
120-
new_field_name = self.sg.schema_field_create("Version", "number", human_field_name,
121-
properties=properties)
133+
new_field_name = self.sg.schema_field_create(
134+
"Version", "number", human_field_name, properties=properties
135+
)
122136

123137
properties = {"description": "How many monkeys turned up"}
124-
ret_val = self.sg.schema_field_update("Version",
125-
new_field_name,
126-
properties)
138+
ret_val = self.sg.schema_field_update("Version", new_field_name, properties)
127139
self.assertTrue(ret_val)
128140

129141
ret_val = self.sg.schema_field_delete("Version", new_field_name)
@@ -132,42 +144,56 @@ def test_schema(self):
132144
def test_schema_with_project(self):
133145
"""Called schema functions with project"""
134146

135-
project_entity = {'type': 'Project', 'id': 0}
147+
project_entity = {"type": "Project", "id": 0}
136148

137149
if not self.sg.server_caps.version or self.sg.server_caps.version < (5, 4, 4):
138-
139150
# server does not support this!
140-
self.assertRaises(shotgun_api3.ShotgunError, self.sg.schema_entity_read, project_entity)
141-
self.assertRaises(shotgun_api3.ShotgunError, self.sg.schema_read, project_entity)
142-
self.assertRaises(shotgun_api3.ShotgunError, self.sg.schema_field_read, 'Version', None, project_entity)
143-
self.assertRaises(shotgun_api3.ShotgunError, self.sg.schema_field_read, 'Version', 'user', project_entity)
151+
self.assertRaises(
152+
shotgun_api3.ShotgunError, self.sg.schema_entity_read, project_entity
153+
)
154+
self.assertRaises(
155+
shotgun_api3.ShotgunError, self.sg.schema_read, project_entity
156+
)
157+
self.assertRaises(
158+
shotgun_api3.ShotgunError,
159+
self.sg.schema_field_read,
160+
"Version",
161+
None,
162+
project_entity,
163+
)
164+
self.assertRaises(
165+
shotgun_api3.ShotgunError,
166+
self.sg.schema_field_read,
167+
"Version",
168+
"user",
169+
project_entity,
170+
)
144171

145172
else:
146-
147173
schema = self.sg.schema_entity_read(project_entity)
148174
self.assertTrue(schema, dict)
149175
self.assertTrue(len(schema) > 0)
150-
self.assertTrue('Project' in schema)
151-
self.assertTrue('visible' in schema['Project'])
176+
self.assertTrue("Project" in schema)
177+
self.assertTrue("visible" in schema["Project"])
152178

153179
schema = self.sg.schema_read(project_entity)
154180
self.assertTrue(schema, dict)
155181
self.assertTrue(len(schema) > 0)
156-
self.assertTrue('Version' in schema)
157-
self.assertFalse('visible' in schema)
182+
self.assertTrue("Version" in schema)
183+
self.assertFalse("visible" in schema)
158184

159-
schema = self.sg.schema_field_read('Version', project_entity=project_entity)
185+
schema = self.sg.schema_field_read("Version", project_entity=project_entity)
160186
self.assertTrue(schema, dict)
161187
self.assertTrue(len(schema) > 0)
162-
self.assertTrue('user' in schema)
163-
self.assertTrue('visible' in schema['user'])
188+
self.assertTrue("user" in schema)
189+
self.assertTrue("visible" in schema["user"])
164190

165-
schema = self.sg.schema_field_read('Version', 'user', project_entity)
191+
schema = self.sg.schema_field_read("Version", "user", project_entity)
166192
self.assertTrue(schema, dict)
167193
self.assertTrue(len(schema) > 0)
168-
self.assertTrue('user' in schema)
169-
self.assertTrue('visible' in schema['user'])
194+
self.assertTrue("user" in schema)
195+
self.assertTrue("visible" in schema["user"])
170196

171197

172-
if __name__ == '__main__':
198+
if __name__ == "__main__":
173199
base.unittest.main()

0 commit comments

Comments
 (0)