Skip to content

Commit

Permalink
1254 added a new API endpoint for ordering properties (#1255)
Browse files Browse the repository at this point in the history
* 1254 added a new API endpoint for ordering properties

* changelog

* added new cassettes for tests

* just for the fun of it I upgrade the requirements.

Co-authored-by: Jochem Berends <jochem.berends@ke-works.com>
  • Loading branch information
raduiordache and Jochem Berends authored Jan 9, 2023
1 parent 3b2a74a commit c4aafa9
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 22 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Change Log
vUNRELEASED
---------------
* :+1: Added the possibility to import `Parts` from an `Excel` file (#931)
* :+1: Added a new endpoint for to help with reordering `Properties` (#1254)

v4.3.0 (7NOV22)
---------------
Expand Down
1 change: 1 addition & 0 deletions pykechain/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"parts_export": "api/v3/parts/export",
'parts_import': 'api/v3/parts/import_parts',
"part": "api/v3/parts/{part_id}.json",
"order_properties": "api/v3/parts/{part_id}/order_properties",
"properties": "api/v3/properties.json",
"properties_bulk_update": "api/v3/properties/bulk_update",
"properties_create_model": "api/v3/properties/create_model",
Expand Down
12 changes: 10 additions & 2 deletions pykechain/models/part.py
Original file line number Diff line number Diff line change
Expand Up @@ -1160,11 +1160,19 @@ def order_properties(
)

properties_fvalues = [
dict(order=order, id=pk) for order, pk in enumerate(property_ids)
dict(id=pk) for pk in property_ids
]

return self.update(properties_fvalues=properties_fvalues)
response = self._client._request(
"POST",
self._client._build_url("order_properties", part_id=self.id),
json=properties_fvalues,
)

if response.status_code != requests.codes.ok: # pragma: no cover
raise APIError(f"Could not reorder Properties of Part {self}", response=response)

return
#
# Utility Functions
#
Expand Down
30 changes: 15 additions & 15 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,35 @@ requests==2.28.1
envparse==0.2.0

# json validation (inspector)
jsonschema==4.6.2
jsonschema==4.17.3

# for version comparison
semver==2.13.0

# testing
pytest==7.1.2
pytest-xdist[psutil]==2.5.0
pytest==7.2.0
pytest-xdist[psutil]==3.1.0
betamax==0.8.1
coverage==6.4.1
pytest-cov==3.0.0
coverage==7.0.4
pytest-cov==4.0.0
coveralls==3.3.1

# documentation
Sphinx==5.0.1
nbsphinx==0.8.9
Sphinx==6.1.2
nbsphinx==0.8.11

# integration
tox==3.25.1
tox==4.2.6

# code style
flake8==4.0.1
importlib-metadata
pydocstyle==6.1.1
mypy==0.961; python_version >= '3.4'
pre-commit==2.19.0
flake8==6.0.0
importlib-metadata==6.0.0
pydocstyle==6.2.3
mypy==0.991; python_version >= '3.4'
pre-commit==2.21.0

# for package management (uploads)
twine~=4.0; python_version >= '3.7'
twine==4.0.2; python_version >= '3.7'
twine~=3.0; python_version <= '3.6'

pytz==2022.1
pytz==2022.7
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"http_interactions": [{"request": {"body": {"encoding": "utf-8", "string": ""}, "headers": {"User-Agent": ["python-requests/2.28.1"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "Connection": ["keep-alive"], "X-Requested-With": ["XMLHttpRequest"], "PyKechain-Version": ["4.2.2"], "Authorization": ["Token <AUTH_TOKEN>"]}, "method": "GET", "uri": "<API_URL>/api/v3/scopes.json?status=ACTIVE&name=Bike+Project&fields=id%2Cname%2Cref%2Ctext%2Ccreated_at%2Cupdated_at%2Cstart_date%2Cdue_date%2Cstatus%2Ccategory%2Cprogress%2Cmembers%2Cteam%2Ctags%2Cscope_options%2Cteam_id_name%2Cworkflow_root_id%2Ccatalog_root_id%2Capp_root_id%2Cproduct_model_id%2Cproduct_instance_id%2Ccatalog_model_id%2Ccatalog_instance_id%2Cproject_info&limit=2"}, "response": {"body": {"encoding": "utf-8", "base64_string": "H4sIAAAAAAAAA7VVwW7jNhD9FUPXmgZJURLp07aLPeyhbdBke2gRGCNp5LCRRIGivGsE/vcO5XUsI2h7SQ8SNI/zZt4MydFLUrmpD8lWrJMev9FHP7XtOhk8HqybxovtcZzaQOafL4mtk21S1lldIQCDNEOmipIz01QZ00WmBG8UZHmTUEzokLx/ss+4uvPuL6xCEqM1MQSBbHgFw5w++e61mkasV8GtAo5hdXd8xuoJbL+Cvl4N0/i0smFefcJVaztL0tbJGCBEycmPHx8+//6JkAoC7p0/Evbl/tNvu/uPv97NuEdaqXcQM0ouDBOcSfnA9ZbnW6U3ulBZmv1BrtNQL12lZFyT94OQWym2mdmkucwLEV0D7GOH5sLI/MbGyg3IAvg9huSRBEZ754ZgXU+eL4k7oPe2xnt6SvDJtoF2xNgg2oAReyro7Ept9+E4xF5W0xhc97lyfSzE9Y3dx1C1HYcWjjMee1sdqzaqWOA/uzoG8LifWkp2OpGkc7Rf4GD3cy5K9XiKmwHdzta78/6dz0CHXYn+egakzqk9I/rvmzxOA/qDHZ2/bjx92XEHVbAHMoOfqDjswLava+eol7UIQA97vPaCoEXkq1+LUF/Is+tpfdZl0htZ8QBF3/9T1BVdqorsi6i3mi4h30XWK/Lfqm56pd7IiuZV0xeyVg8E/5s4+FBu+vY9O3ejUbw9Zbci7xfQP4p8crHlY0D/w2C7lMVaP9AAmsfKpnLdu+/8Yxyj8zDb2b5x8WbNM8qHXRwpl2tVT3hjE2dPl5/uGd+YQmc8k0bw+OZmnXx1/rlp3dedd47ixlHMBa/znCumsqpkSleKaZUVLE+bjGuZg9LNeRZC6/YLYt2gopnNmTK5ZKoxwIzSghVYyhq0KJQEIsIwLEhpCalWqJgsCkEkzhlQFlZK3Yg8S2su82Suop6o8o5mTntmGq2VEVIxYZRhKucpMwiSCWWMKoFmK4cF0/bUq77CMxlyXqSoSpYZAVSpSCljEX86kAsoJaRVuihykbbMc6GqTDCZZcSUaJhOpWZK0NxGkdZQFAvmbVrDKTAawVCLnCgcWFmRAJHn9NtQGTQyTU6Pp78BzXj/dkgHAAA=", "string": ""}, "headers": {"Server": ["nginx"], "Date": ["Wed, 10 Aug 2022 12:27:37 GMT"], "Content-Type": ["application/json"], "Transfer-Encoding": ["chunked"], "Connection": ["keep-alive"], "Vary": ["Accept-Encoding", "Accept, Accept-Language, Cookie"], "allow": ["GET, POST, HEAD, OPTIONS"], "x-frame-options": ["SAMEORIGIN"], "content-language": ["en", "En"], "strict-transport-security": ["max-age=15768000; includeSubDomains"], "x-content-type-options": ["nosniff"], "x-xss-protection": ["1; mode=block"], "referrer-policy": ["same-origin"], "Ke-Chain": ["3"], "Content-Encoding": ["gzip"]}, "status": {"code": 200, "message": "OK"}, "url": "<API_URL>/api/v3/scopes.json?status=ACTIVE&name=Bike+Project&fields=id%2Cname%2Cref%2Ctext%2Ccreated_at%2Cupdated_at%2Cstart_date%2Cdue_date%2Cstatus%2Ccategory%2Cprogress%2Cmembers%2Cteam%2Ctags%2Cscope_options%2Cteam_id_name%2Cworkflow_root_id%2Ccatalog_root_id%2Capp_root_id%2Cproduct_model_id%2Cproduct_instance_id%2Ccatalog_model_id%2Ccatalog_instance_id%2Cproject_info&limit=2"}, "recorded_at": "2022-08-10T12:27:37"}, {"request": {"body": {"encoding": "utf-8", "string": ""}, "headers": {"User-Agent": ["python-requests/2.28.1"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "Connection": ["keep-alive"], "X-Requested-With": ["XMLHttpRequest"], "PyKechain-Version": ["4.2.2"], "Authorization": ["Token <AUTH_TOKEN>"]}, "method": "GET", "uri": "<API_URL>/api/v3/parts.json?name=Front+Fork&category=MODEL&limit=2&scope_id=bd5dceaa-a35e-47b0-9fc5-875410f4a56f&fields=id%2Cname%2Cref%2Cdescription%2Ccreated_at%2Cupdated_at%2Cproperties%2Ccategory%2Cclassification%2Cparent_id%2Cmultiplicity%2Cvalue_options%2Cproperty_type%2Cvalue%2Coutput%2Corder%2Cpart_id%2Cscope_id%2Cmodel_id%2Cproxy_source_id_name%2Cunit"}, "response": {"body": {"encoding": "utf-8", "base64_string": "H4sIAAAAAAAAA9WTS0/cMBDHv0qVM0Z+P3JDPMQB2AotPVBVkdeegNUQR06CWCG+ex32wapVBYiqak/JzPzH9sxv5rFwcWyHoiR7RQsP+acdm2av6BLchzj2GztBPzZDNr8+FsEXZaGoUVBbhaTGFnEsAC2UJQgYNpYDZtjTIp9p7yCrT1Jsh08nMX0vprPq7KonF6pXLg+9S6EbQmxzKDucHeAmpmW2zmdHx2eTq7F9H+qQQyvZ58vZ0dXhPIfu8ttC1wQXhiljdnE86RPkQ3xlc1EFxcQgghGlc6xLLEtu9iWTApPrLB07vyulFGGd1XNCSypKTPapFpqJSdq72EH13IKFF96BtciyXD1XC4xM7QTSSnCCa26FrHNGZxO0wyoFuMVcWYnyFyNO8t/CAkeKUetoLZnxMNUTPTTPGRsa8WFZ9XFMbrq7WnV1G+sgDQF24BhtvZVSI6yml2FpkLYGI+asciCtYI6/wDnPtadgmy2auxfHL2DW1y2rYdlNyYenB5fVl4Ozq+N3U4vJQypKnPvfhu3k3dtmhCo+X5lLenxauzbx17Gq3H/2G6wKUT1JqSo525eCECavV5DWiN442O+fg/dAjePQjfnVQxrhaW9NVRMhLDMSSSkp4p5QpGsJSJoFt3l2tMP1C9VTCDe3w5bp7cZ8lejJ2exg/jGkZIO0uIjtNNAfhqoIz+W/GSrX/wtUyryuwWkkiVaIG8WQ1p4iQwk4Y/O+qp1VPYxNTFumbm39hSWlf3hJlcBKqzfzFPRf5/ntZ/vpB9vYM4FbBwAA", "string": ""}, "headers": {"Server": ["nginx"], "Date": ["Wed, 10 Aug 2022 12:27:38 GMT"], "Content-Type": ["application/json"], "Transfer-Encoding": ["chunked"], "Connection": ["keep-alive"], "Vary": ["Accept-Encoding", "Accept, Accept-Language, Cookie"], "allow": ["GET, POST, HEAD, OPTIONS"], "x-frame-options": ["SAMEORIGIN"], "content-language": ["en", "En"], "strict-transport-security": ["max-age=15768000; includeSubDomains"], "x-content-type-options": ["nosniff"], "x-xss-protection": ["1; mode=block"], "referrer-policy": ["same-origin"], "Ke-Chain": ["3"], "Content-Encoding": ["gzip"]}, "status": {"code": 200, "message": "OK"}, "url": "<API_URL>/api/v3/parts.json?name=Front+Fork&category=MODEL&limit=2&scope_id=bd5dceaa-a35e-47b0-9fc5-875410f4a56f&fields=id%2Cname%2Cref%2Cdescription%2Ccreated_at%2Cupdated_at%2Cproperties%2Ccategory%2Cclassification%2Cparent_id%2Cmultiplicity%2Cvalue_options%2Cproperty_type%2Cvalue%2Coutput%2Corder%2Cpart_id%2Cscope_id%2Cmodel_id%2Cproxy_source_id_name%2Cunit"}, "recorded_at": "2022-08-10T12:27:38"}], "recorded_with": "betamax/0.8.1"}
{"http_interactions": [{"request": {"body": {"encoding": "utf-8", "string": ""}, "headers": {"User-Agent": ["python-requests/2.28.1"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "Connection": ["keep-alive"], "X-Requested-With": ["XMLHttpRequest"], "PyKechain-Version": ["4.3.0"], "Authorization": ["Token <AUTH_TOKEN>"]}, "method": "GET", "uri": "<API_URL>/api/v3/scopes.json?status=ACTIVE&name=Bike+Project&fields=id%2Cname%2Cref%2Ctext%2Ccreated_at%2Cupdated_at%2Cstart_date%2Cdue_date%2Cstatus%2Ccategory%2Cprogress%2Cmembers%2Cteam%2Ctags%2Cscope_options%2Cteam_id_name%2Cworkflow_root_id%2Ccatalog_root_id%2Capp_root_id%2Cproduct_model_id%2Cproduct_instance_id%2Ccatalog_model_id%2Ccatalog_instance_id%2Cproject_info&limit=2"}, "response": {"body": {"encoding": "utf-8", "base64_string": "H4sIAAAAAAAAA7VVwY7jNgz9lcDXRoEky7aU07aLPeyh7aAz20OLQUDbdEYd2zJkObvBIP9eytlMHAzaXqaHAOYTH/lISsxLUrmpD8lWrJMev9FHP7XtOhk8HqybxovtcZzaQOafL4mtk21S1lldIQCDNEOmipIz01QZ00WmBG8UZHmTUEzokLx/ss+4uvPuL6xCEqM1MQSBbHgFw5w++e61mkasV8GtAo5hdXd8xuoJbL+Cvl4N0/i0smE+fcJVaztL0tbJGCBEycmPHx8+//6JkAoC7p0/Evbl/tNvu/uPv97NuEc6qXcQM0ouDBOcSfnA9ZbnW6U3ulBZmv1BrtNQL12lZNwwTq5mK+Q2Sze55Kk00TXAPnZoLozMb2ys3IAsgN9jSB5JYLR3bgjW9eT5krgDem9rvKdfCT7ZNtCOGBtEAxixp4LOrtR2H45D7GU1jcF1nyvXx0Jc39h9DFXbcWjhOOOxt9WxaqOKBf6zq2MAj/uppWSnE0k6R/sFDnY/56JUj6c4DOh2tt6d53e+Ax12JfrrHZA6p/aM6L8PeZwG9Ac7On8dPH3ZcQdVsAcyg5+oOOzAtq9n56iXswhAD3u89oKgReSrX4tQX8iz62l91mXSG1nxAkXf/1PUFV2qiuyLqLeaLiHfRdYr8t+qbnql3siK5lXTF7JWDwT/mzj4UG769j07d6NRvL1ltyLvF9A/inxyseVjQP/DYLuUxVo/0AKa18qmct27T/4xrtF5me1s37j4suYd5cMurpTLs6onvLGJs6fHT++Mb7TUSqdSZUIZI4ReJ1+df25a93XnnaO4cRVzwes854qprCqZ0pViWmUFy9Mm41rmoHRz3oXQuv2CWDeoaGdzpkwumWoMMKO0YAWWsgYtCiWBiDAMC1JaQqoVKiaLQhCJcwaUhZVSNyLP0prLPJmrqCeqvKOd056ZRmtlhFRMGGWYynnKDIJksTZVAu1WDgum7alXfYVnMuS8SFGVLDMCqFKRUsYi/ulALqCUkFbposhF2jLPhaoywWSWEVOiYdRSzZSQeYEiraEoFszbtIZTYDSCoRY5UTiwsiIBIqe1L1QGjUyT0+Ppb98q/jhIBwAA", "string": ""}, "headers": {"Server": ["nginx"], "Date": ["Mon, 09 Jan 2023 09:44:42 GMT"], "Content-Type": ["application/json"], "Transfer-Encoding": ["chunked"], "Connection": ["keep-alive"], "Vary": ["Accept-Encoding", "Accept, Accept-Language, Cookie"], "allow": ["GET, POST, HEAD, OPTIONS"], "x-frame-options": ["SAMEORIGIN"], "content-language": ["en", "En"], "strict-transport-security": ["max-age=15768000; includeSubDomains"], "x-content-type-options": ["nosniff"], "x-xss-protection": ["1; mode=block"], "referrer-policy": ["same-origin"], "Ke-Chain": ["3"], "Content-Encoding": ["gzip"]}, "status": {"code": 200, "message": "OK"}, "url": "<API_URL>/api/v3/scopes.json?status=ACTIVE&name=Bike+Project&fields=id%2Cname%2Cref%2Ctext%2Ccreated_at%2Cupdated_at%2Cstart_date%2Cdue_date%2Cstatus%2Ccategory%2Cprogress%2Cmembers%2Cteam%2Ctags%2Cscope_options%2Cteam_id_name%2Cworkflow_root_id%2Ccatalog_root_id%2Capp_root_id%2Cproduct_model_id%2Cproduct_instance_id%2Ccatalog_model_id%2Ccatalog_instance_id%2Cproject_info&limit=2"}, "recorded_at": "2023-01-09T09:44:42"}, {"request": {"body": {"encoding": "utf-8", "string": ""}, "headers": {"User-Agent": ["python-requests/2.28.1"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "Connection": ["keep-alive"], "X-Requested-With": ["XMLHttpRequest"], "PyKechain-Version": ["4.3.0"], "Authorization": ["Token <AUTH_TOKEN>"]}, "method": "GET", "uri": "<API_URL>/api/v3/parts.json?name=Front+Fork&category=MODEL&limit=2&scope_id=bd5dceaa-a35e-47b0-9fc5-875410f4a56f&fields=id%2Cname%2Cref%2Cdescription%2Ccreated_at%2Cupdated_at%2Cproperties%2Ccategory%2Cclassification%2Cparent_id%2Cmultiplicity%2Cvalue_options%2Cproperty_type%2Cvalue%2Coutput%2Corder%2Cpart_id%2Cscope_id%2Cmodel_id%2Cproxy_source_id_name%2Cunit"}, "response": {"body": {"encoding": "utf-8", "base64_string": "H4sIAAAAAAAAA9WTS0/cQAzHv0qVM4Pm/cgN8RAHYCu09EBVRbMTB6KGTDRJECvEd6/DPli1lQBRVe0psf33zNg/+zELcWyHLGd7WQsP+NOOTbOXdQnu6zj2GztBPzYDml8fs7rM8sxwZ6DyhmhLPZFUAVkYzwgI6rwEKmjJMzzT3wGqT1Jsh08nMX3PprMqdFWTi1QrVwl9SHU31LHFEDqCH+AmpiVa57Oj47PJ1fi+r6saQyvZ58vZ0dXhHEN3+La6a+pQD1PG7OJ40ifAQ8rCY1EZp8wRRgnnc2pzqnPp9rXQirJrlI5duSvlnFCL6jnjOVc5ZfvcKivUJO1D7KB4bsGiVGUA74kXWL00C0pcFRSxRklGK+mVrjCj8wnaYZUC0lNpvCb4pUQy/Ft4kMQI7gOvtHAlTPXEEprnjA2N+LAs+jimMN1drLq6jXWQhhp24DjrS6+1JdRML6PaEesdJSJ4E0B7JYJ8gXOOtafaN1s0dy+OX8Csr1sWw7Kbkg9PDy6LLwdnV8fvphZTCSnLOfa/rbeTd++bEYr4fCWW9Pi0dm3ir2M12H/xO6yCUEaom1OXC5czi1JutLleQVojeuNgv38O3gM1jkM34quHNMLT3pqqZUp54TTRWnMiS8aJrTQQ7RbS4+zYQKsXqqdQ39wOW6a3G/NVoidns4P5x5CyDdLsIrbTQH8YqmESy387VPG/QOWitBUESzSzhkhnBLG25MRxBsF53Fezs6qHsYlpyzSsrb+wpPQPL6lR1FjzZp6K/us8v/1sP/0AtMXSvFsHAAA=", "string": ""}, "headers": {"Server": ["nginx"], "Date": ["Mon, 09 Jan 2023 09:44:42 GMT"], "Content-Type": ["application/json"], "Transfer-Encoding": ["chunked"], "Connection": ["keep-alive"], "Vary": ["Accept-Encoding", "Accept, Accept-Language, Cookie"], "allow": ["GET, POST, HEAD, OPTIONS"], "x-frame-options": ["SAMEORIGIN"], "content-language": ["en", "En"], "strict-transport-security": ["max-age=15768000; includeSubDomains"], "x-content-type-options": ["nosniff"], "x-xss-protection": ["1; mode=block"], "referrer-policy": ["same-origin"], "Ke-Chain": ["3"], "Content-Encoding": ["gzip"]}, "status": {"code": 200, "message": "OK"}, "url": "<API_URL>/api/v3/parts.json?name=Front+Fork&category=MODEL&limit=2&scope_id=bd5dceaa-a35e-47b0-9fc5-875410f4a56f&fields=id%2Cname%2Cref%2Cdescription%2Ccreated_at%2Cupdated_at%2Cproperties%2Ccategory%2Cclassification%2Cparent_id%2Cmultiplicity%2Cvalue_options%2Cproperty_type%2Cvalue%2Coutput%2Corder%2Cpart_id%2Cscope_id%2Cmodel_id%2Cproxy_source_id_name%2Cunit"}, "recorded_at": "2023-01-09T09:44:42"}], "recorded_with": "betamax/0.8.1"}
Loading

0 comments on commit c4aafa9

Please sign in to comment.