Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/110-inspector-helper-classes' in…
Browse files Browse the repository at this point in the history
…to 110-inspector-helper-classes
  • Loading branch information
Jochem Berends committed Jun 22, 2017
2 parents c022b37 + 33e5ee4 commit dfb8c32
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion pykechain/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,11 +492,12 @@ def create_proxy_model(self, model, parent, name, multiplicity='ZERO_MANY'):

return self._create_part('create_proxy_model', data)

def create_property(self, model, name, property_type='CHAR', default_value=None):
def create_property(self, model, name, description, property_type='CHAR', default_value=None):
"""Create a new property model under a given model.
:param model: parent model
:param name: property model name
:param description: property model description
:param property_type: choose between FLOAT, INT, TEXT, LINK, REFERENCE, DATETIME, BOOLEAN, CHAR, ATTACHMENT or
SINGLE_SELECT
:param default_value: default value used for part instances
Expand All @@ -507,6 +508,7 @@ def create_property(self, model, name, property_type='CHAR', default_value=None)
data = {
"name": name,
"part": model.id,
"description": description,
"property_type": property_type.upper() + '_VALUE',
"value": default_value
}
Expand Down
2 changes: 1 addition & 1 deletion pykechain/models/property_selectlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def options(self, options_list):

# stringify the options list
options_list = list(map(str, options_list))
if set(options_list) != set(self._options):
if set(options_list) != self._options:
self._put_options(options_list=options_list)
self._options = options_list

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"http_interactions": [{"request": {"headers": {"Accept-Encoding": "gzip, deflate", "Accept": "*/*", "Connection": "keep-alive", "PyKechain-Version": "1.7.1", "User-Agent": "python-requests/2.17.3", "Authorization": "Token <AUTH_TOKEN>", "X-Requested-With": "XMLHttpRequest"}, "body": {"encoding": "utf-8", "string": ""}, "uri": "<API_URL>/api/scopes.json?name=Bike+Project+%28pykechain+testing%29&status=ACTIVE", "method": "GET"}, "recorded_at": "2017-06-22T07:12:31", "response": {"url": "<API_URL>/api/scopes.json?name=Bike+Project+%28pykechain+testing%29&status=ACTIVE", "headers": {"Allow": "GET, POST, OPTIONS", "X-Content-Type-Options": "nosniff", "Connection": "keep-alive", "X-Frame-Options": "SAMEORIGIN", "Server": "nginx/1.10.2", "Strict-Transport-Security": "max-age=518400; includeSubDomains", "Date": "Thu, 22 Jun 2017 07:12:31 GMT", "Transfer-Encoding": "chunked", "Content-Type": "application/json", "Content-Encoding": "gzip", "X-XSS-Protection": "1; mode=block", "Vary": "Accept-Encoding"}, "body": {"encoding": null, "string": "", "base64_string": "H4sIAAAAAAAAA61T24rbMBD9lUVPLUSOLNmWladtt/tQKLTQpQ8tJegyTpzYcpDkXgj5945z2Q2U0lIW22CNzplzRprZkwBx7FIkiy97MoaOLMg6pV1czOdbsFzv2mwL1K516zM79HMMzKMddhDnVSONVQ2jnNdACyc0Vc4yCrbUsnRSQO6yTRw8mZHWYeJ/ISDW6x4Q/brdws2HMGzAppsXu59oZ3JxkyCm1q9eIjLBj4RI/ItJpxGLIK/uHt5+up/2gvaxTe3gT7U9Iu7evf94/+ZJ57jG5bpdrTv8EqDXFEY4fJ0RHWO78oA4P3bdjPTQGwinjGf+VF1c9trrFYQT8xQ5Qq8C2qb2G1wCY4RwzrAZ7Br6DNHgXcR80Ou2+23jFi/i+xC2cbqI85lWh9kzGpmO9sJ/cmFuTea7syD/s2Cju/g/itPySk5fy4lnre+xia7kzkJyum3skZCWTqcJzFkuKcsprx64WDCG72cEuxH+gjCj3QL25Z70g4NuGYZh6lKpuBbWAGWirLD7VUHrom6osdY0RnDWWDGZ8ejCW7jQmpLnQgigOgdHC6hKavKqokqpRuVa1LbJLwNWMIbJuaQ5Ti4tZKVpzSUOmJGl5FApAEYOM7ILg4U4DQNzGkolFK2FsLSopaZGVQVlpSusANWAVeRIWIUjg2Wyzq8fhUfp2qRNB5exOfwCripgPVYEAAA="}, "status": {"message": "OK", "code": 200}}}, {"request": {"headers": {"Accept-Encoding": "gzip, deflate", "Accept": "*/*", "Connection": "keep-alive", "PyKechain-Version": "1.7.1", "User-Agent": "python-requests/2.17.3", "Authorization": "Token <AUTH_TOKEN>", "X-Requested-With": "XMLHttpRequest"}, "body": {"encoding": "utf-8", "string": ""}, "uri": "<API_URL>/api/parts.json?limit=100&name=Bike&category=MODEL&bucket=40003527-1c2a-476a-8270-eb7572e69ee0", "method": "GET"}, "recorded_at": "2017-06-22T07:12:31", "response": {"url": "<API_URL>/api/parts.json?limit=100&name=Bike&category=MODEL&bucket=40003527-1c2a-476a-8270-eb7572e69ee0", "headers": {"Allow": "GET, POST, OPTIONS", "X-Content-Type-Options": "nosniff", "Connection": "keep-alive", "X-Frame-Options": "SAMEORIGIN", "Server": "nginx/1.10.2", "Strict-Transport-Security": "max-age=518400; includeSubDomains", "Date": "Thu, 22 Jun 2017 07:12:31 GMT", "Transfer-Encoding": "chunked", "Content-Type": "application/json", "Content-Encoding": "gzip", "X-XSS-Protection": "1; mode=block", "Vary": "Accept-Encoding"}, "body": {"encoding": null, "string": "", "base64_string": "H4sIAAAAAAAAA82XbW/iRhDHv0rk19nE633mTcUlvmtU8qCEaytVUbQP4+DGYGQvd4mifPeO4QhcaAVqqS68QOx6mZ35eWb+u8+Jr2eTmPToYTKBR/wxmVXVYTJt4EtZz9rluIF2VkUc/vGclCHpJYIFycE5QtOgCZdOEyelId5mUlsIklGWHCazpsLFoxinbe/4+AF8Zqfl0QMQP7Ll5MjX42OcOJ7aJrbHu9g8+rOtJ2h4YseAlj+UD4CjAK1vymks8VkvwQk/KqtwN64DVK8xzEerAOspNLGERUyzSfka+xdbzWA58DbCfd08odnzy9N8gLbr+T74v+eXw6SNzczHWQN38WnaeXS1MPyEC+egjGJSKiWJ4JwTzhUlWolACq8Kw5WlGU9X8XwC27TdHrM4naFHaB1enX1a7nF2Mbz7tT/4nHcrmwBN0tO4CiHu/mbWaLwc/p8APKPGKpMRUxggXBhLTFoEYmghMsOYkA5WAIZ1tNXBCMr7UdzK4ePgsr9BwrxbEg6Y8VQVJIPUEe6yjFgBkhSKBicdp0zQFYmrcm5sK4T+cNg/+fk838wJ+m5JGEkpFFwQrA0sClEURMtUEOWBeTBp6plekThdq+5tNIb57xsc5LvlYIVTMjDMA+AW/bFYJc4pYiTzystUSb3WHPLHadmUk/uDgPtuJXHaH+bDs/P8LQ31bmlwCjLLAiVSgMJWiV/GIhwlbUoF8zwza/XxG7i23IHD4Ozil7cM+LtlID1obbwiYJwkHKQkzgtOdCE5T4Fqk8oVgxtbwU9bCXy4vBzk/Yu3EMReIHRq+w3BXOdR5r9+PYJHOxpPK+gUPtkDFuYKpQXFrBCYH5gZDlMDlQTngXKbBg5hhaUqJw/d51/lBk33zWWH1FgsvfOjuvTzIwnG0Mbkdhc2oJjWGsWEcocCK32KUisUpowvulwqMi1WbFqowMeDuflteG7OLj4N8rubfJCfbKrLfuRljdPza2mPABcuwwteg7Mp4coLwimenbTKFJHBZEpwBsBc8rKHHCuKToQNmrep73ZjRKeaEi+FxgdOKFusOF5DMYQdGF7nH/Pr/OJkow/T7Afk2W75JKjlDM+pzCD11HL0BgQxgTPOgzOWrh9TRnWsD/oxWj8aw2Q7kH8+r/yIwtup+WjvIbOAumTx3FaknBhlA6FMpdyAEcKvA6nquB8e7zVBnGLOBZciAI0VyVOKGoV1I0WWObzQZMGtNeN8PI1PB3YfQNh/AXL7t5H7yrZtWZT4aHF5vLq+PP18MpxfKiuI1lWwdBRC+d34+zA2sXWuzj3uol51N8QZcOWBrycRL8EY2DeuQmmaQVaQgmlUOikZsRw1z6LoK6kC9nLoOt0Yr+LltCp9GbtQLi86RCtrvcJW7YLr49PypY9se9fO3KuT7cLtl9uXvwCudLblAxAAAA=="}, "status": {"message": "OK", "code": 200}}}, {"request": {"headers": {"Accept-Encoding": "gzip, deflate", "Accept": "*/*", "Connection": "keep-alive", "PyKechain-Version": "1.7.1", "User-Agent": "python-requests/2.17.3", "Authorization": "Token <AUTH_TOKEN>", "X-Requested-With": "XMLHttpRequest", "Content-Type": "application/x-www-form-urlencoded", "Content-Length": "122"}, "body": {"encoding": "utf-8", "string": "description=Nice+prop&property_type=CHAR_VALUE&name=New+property&value=EURIKA%21&part=53d64ebb-10d8-46b8-b669-ca268aed6313"}, "uri": "<API_URL>/api/properties.json", "method": "POST"}, "recorded_at": "2017-06-22T07:12:31", "response": {"url": "<API_URL>/api/properties.json", "headers": {"Allow": "GET, POST, OPTIONS", "X-Frame-Options": "SAMEORIGIN", "Vary": "Accept, Cookie", "Connection": "keep-alive", "Date": "Thu, 22 Jun 2017 07:12:31 GMT", "Server": "nginx/1.10.2", "X-Content-Type-Options": "nosniff", "X-XSS-Protection": "1; mode=block", "Strict-Transport-Security": "max-age=518400; includeSubDomains", "Content-Type": "application/json", "Transfer-Encoding": "chunked"}, "body": {"encoding": null, "string": "{\"results\":[{\"id\":\"9b181110-2fa4-41e5-8674-17d69f4dcd5c\",\"category\":\"MODEL\",\"name\":\"New property\",\"description\":\"Nice prop\",\"value\":\"EURIKA!\",\"property_type\":\"CHAR_VALUE\",\"unit\":null,\"created_at\":\"2017-06-22T07:12:31.716141Z\",\"updated_at\":\"2017-06-22T07:12:31.742215Z\",\"structure_type\":\"Property\",\"editable\":true,\"deletable\":true,\"output\":true,\"part\":\"53d64ebb-10d8-46b8-b669-ca268aed6313\",\"model\":null,\"options\":{}}]}"}, "status": {"message": "Created", "code": 201}}}, {"request": {"headers": {"Accept-Encoding": "gzip, deflate", "Accept": "*/*", "Connection": "keep-alive", "PyKechain-Version": "1.7.1", "User-Agent": "python-requests/2.17.3", "Authorization": "Token <AUTH_TOKEN>", "X-Requested-With": "XMLHttpRequest", "Content-Length": "0"}, "body": {"encoding": "utf-8", "string": ""}, "uri": "<API_URL>/api/properties/9b181110-2fa4-41e5-8674-17d69f4dcd5c.json", "method": "DELETE"}, "recorded_at": "2017-06-22T07:12:31", "response": {"url": "<API_URL>/api/properties/9b181110-2fa4-41e5-8674-17d69f4dcd5c.json", "headers": {"X-Content-Type-Options": "nosniff", "X-Frame-Options": "SAMEORIGIN", "Vary": "Accept, Cookie", "Connection": "keep-alive", "Date": "Thu, 22 Jun 2017 07:12:31 GMT", "Server": "nginx/1.10.2", "Allow": "GET, PUT, PATCH, DELETE, OPTIONS", "X-XSS-Protection": "1; mode=block", "Strict-Transport-Security": "max-age=518400; includeSubDomains", "Content-Type": "application/json", "Content-Length": "0"}, "body": {"encoding": null, "string": ""}, "status": {"message": "No Content", "code": 204}}}], "recorded_with": "betamax/0.8.0"}

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions tests/test_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def test_create_and_delete_property_model(self):
bike = self.project.model('Bike')

# test creation of new property model of bike
new_property = bike.add_property(name='New property', property_type='CHAR',
default_value='EUREKA!')
new_property = self.client.create_property(model=bike, name='New property', description='Nice prop',
property_type='CHAR', default_value='EURIKA!')

# check whether the property has been created and whether it's name and type are correct
self.assertIsInstance(bike.property('New property'), Property)
Expand Down

0 comments on commit dfb8c32

Please sign in to comment.