Skip to content

Commit

Permalink
Implement named property fetching
Browse files Browse the repository at this point in the history
  • Loading branch information
artemgordinskiy committed Apr 2, 2020
1 parent a17f165 commit f85f14d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
8 changes: 8 additions & 0 deletions hubspot3/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,14 @@ def get_all(self, object_type):
"", method="GET", params={"properties": ["name", "label", "description"]}
)

def get(self, object_type: str, code: str):
"""Retrieve a property."""

# Save the current object type.
self._object_type = object_type

return self._call("named/{}".format(code), method="GET")

def delete(self, object_type, code):
"""Delete a custom property."""

Expand Down
24 changes: 23 additions & 1 deletion hubspot3/test/test_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def properties_input_data():
)


class TestContactsClient(object):
class TestPropertiesClient(object):
@pytest.mark.parametrize(
"object_type, api_version",
[
Expand Down Expand Up @@ -153,3 +153,25 @@ def test_update(
data,
)
assert resp == response_body

def test_get(self, properties_client, mock_connection, properties_input_data):
input_data = properties_input_data
response_body = {
"name": input_data["code"],
"label": input_data["label"],
"description": input_data["description"],
"groupName": "custom",
"type": "string",
"fieldType": "text",
"formField": True,
"displayOrder": 3,
"options": [],
}
mock_connection.set_response(200, json.dumps(response_body))
resp = properties_client.get(OBJECT_TYPE_DEALS, input_data["code"])
mock_connection.assert_num_requests(1)
mock_connection.assert_has_request(
"GET",
"/properties/v1/deals/properties/named/{}?".format(input_data["code"]),
)
assert resp == response_body

0 comments on commit f85f14d

Please sign in to comment.