Ejemplo n.º 1
0
"""
testing hubspot3.deals
"""
import pytest
from hubspot3.deals import DealsClient
from hubspot3.error import HubspotNotFound, HubspotBadRequest
from hubspot3.test.globals import TEST_KEY


DEALS = DealsClient(api_key=TEST_KEY)

DEFAULT_DEAL_PROPERTIES = ["dealname", "createdate"]


def _is_deal(deal: dict) -> bool:
    """performs some checking on the data in the deal"""
    assert deal
    assert all([x in deal for x in DEFAULT_DEAL_PROPERTIES])
    return True


def test_get_deal():
    """
    attempts to get a deal via id
    :see: https://developers.hubspot.com/docs/methods/deals/get_deal
    """
    with pytest.raises(HubspotNotFound):
        DEALS.get("-1")

    deal_check = DEALS.get("852832561")
    assert _is_deal(deal_check["properties"])
Ejemplo n.º 2
0
    def deals(self):
        """returns a hubspot3 deals client"""
        from hubspot3.deals import DealsClient

        return DealsClient(**self.auth, **self.options)