Beispiel #1
0
def test_sync_errors_first_run(settings, mock_hubspot_errors, mock_logger):
    """Test that HubspotErrorCheck is created on 1st run and nothing is logged"""
    settings.HUBSPOT_API_KEY = "dkfjKJ2jfd"
    assert HubspotErrorCheck.objects.count() == 0
    check_hubspot_api_errors()
    assert HubspotErrorCheck.objects.count() == 1
    assert mock_hubspot_errors.call_count == 1
    assert mock_logger.call_count == 0
Beispiel #2
0
def test_ignore_hubspot_b2b_line_error(settings, mock_hubspot_b2b_line_error,
                                       mock_logger):
    """Test that a b2b line error is ignored"""
    HubspotErrorCheckFactory.create(checked_on=TIMESTAMPS[0])
    settings.HUBSPOT_API_KEY = "dkfjKJ2jfd"
    check_hubspot_api_errors()
    assert mock_hubspot_b2b_line_error.call_count == 2
    assert HubspotLineResync.objects.count() == 0
    mock_logger.assert_not_called()
Beispiel #3
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
Beispiel #4
0
def test_sync_errors_new_errors(
    settings,
    mock_hubspot_errors,
    mock_logger,
    last_check_dt,
    expected_errors,
    call_count,
):  # pylint: disable=too-many-arguments
    """Test that errors more recent than last checked_on date are logged"""
    settings.HUBSPOT_API_KEY = "dkfjKJ2jfd"
    last_check = HubspotErrorCheckFactory.create(checked_on=last_check_dt)
    check_hubspot_api_errors()
    assert mock_hubspot_errors.call_count == call_count
    assert mock_logger.call_count == expected_errors
    assert HubspotErrorCheck.objects.first().checked_on > last_check.checked_on
Beispiel #5
0
def test_skip_error_checks(settings, mock_hubspot_errors):
    """Test that no requests to Hubspot are made if the HUBSPOT_API_KEY is not set """
    settings.HUBSPOT_API_KEY = None
    check_hubspot_api_errors()
    assert mock_hubspot_errors.call_count == 0