Example #1
0
def test_product_version_save_text_id_badproduct(mocker):
    """ProductVersion.text_id should None if ProductVersion.product is invalid"""
    mock_log = mocker.patch("ecommerce.models.log")
    product_version = ProductVersionFactory.create(
        product=ProductFactory.create(content_object=LineFactory()))
    assert product_version.text_id is None
    assert mock_log.called_once_with(
        f"The content object for this ProductVersion ({product_version.id}) does not have a `text_id` property"
    )
Example #2
0
def test_create_hubspot_line_resync(settings, mock_hubspot_line_error,
                                    mock_retry_lines):
    """Test that lines are re-synced if the error is INVALID_ASSOCIATION_PROPERTY and the order has since been synced"""
    HubspotErrorCheckFactory.create(checked_on=TIMESTAMPS[0])
    order = OrderFactory(id=FAKE_OBJECT_ID)
    line = LineFactory(order=order, id=FAKE_OBJECT_ID)

    settings.HUBSPOT_API_KEY = "dkfjKJ2jfd"
    check_hubspot_api_errors()
    assert mock_hubspot_line_error.call_count == 2
    assert mock_retry_lines.call_count == 1
    assert HubspotLineResync.objects.count() == 1
    assert HubspotLineResync.objects.first().line == line
Example #3
0
def test_make_line_item_sync_message():
    """Test make_line_item_sync_message serializes a line_item and returns a properly formatted sync message"""
    line = LineFactory()
    line_item_sync_message = api.make_line_item_sync_message(line.id)

    serialized_line = LineSerializer(line).data
    assert line_item_sync_message == [
        {
            "integratorObjectId": "{}-{}".format(settings.HUBSPOT_ID_PREFIX, line.id),
            "action": "UPSERT",
            "changeOccurredTimestamp": any_instance_of(int),
            "propertyNameToValues": serialized_line,
        }
    ]