Skip to content

Commit

Permalink
Fix syncing hubspot user (#2219)
Browse files Browse the repository at this point in the history
* Fix syncing hubspot user

* Add tests to ensure hubspot sync
  • Loading branch information
collinpreston authored May 22, 2024
1 parent d09c972 commit 448e8cc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion courses/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ def handle_create_course_run_certificate(
lambda: generate_multiple_programs_certificate(user, programs)
)
call_command("configure_hubspot_properties")
sync_hubspot_user(instance)
sync_hubspot_user(instance.user)
9 changes: 6 additions & 3 deletions courses/signals_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_create_course_certificate(generate_program_cert_mock, mock_on_commit, m
Test that generate_multiple_programs_certificate is called when a course
certificate is created
"""
mocker.patch(
mocked_hubspot_contact_sync = mocker.patch(
"hubspot_sync.management.commands.configure_hubspot_properties._upsert_custom_properties",
)
user = UserFactory.create()
Expand All @@ -36,6 +36,7 @@ def test_create_course_certificate(generate_program_cert_mock, mock_on_commit, m
generate_program_cert_mock.assert_called_once_with(user, [program])
cert.save()
generate_program_cert_mock.assert_called_once_with(user, [program])
mocked_hubspot_contact_sync.assert_called_once()


@patch("courses.signals.transaction.on_commit", side_effect=lambda callback: callback())
Expand All @@ -46,7 +47,7 @@ def test_generate_program_certificate_if_not_live(
"""
Test that generate_multiple_programs_certificate is not called when a program is not live
"""
mocker.patch(
mocked_hubspot_contact_sync = mocker.patch(
"hubspot_sync.management.commands.configure_hubspot_properties._upsert_custom_properties",
)
user = UserFactory.create()
Expand All @@ -57,6 +58,7 @@ def test_generate_program_certificate_if_not_live(
generate_program_cert_mock.assert_not_called()
cert.save()
generate_program_cert_mock.assert_not_called()
mocked_hubspot_contact_sync.assert_called_once()


# pylint: disable=unused-argument
Expand All @@ -69,7 +71,7 @@ def test_generate_program_certificate_not_called(
Test that generate_multiple_programs_certificate is not called when a course
is not associated with program.
"""
mocker.patch(
mocked_hubspot_contact_sync = mocker.patch(
"hubspot_sync.management.commands.configure_hubspot_properties._upsert_custom_properties",
)
user = UserFactory.create()
Expand All @@ -78,3 +80,4 @@ def test_generate_program_certificate_not_called(
cert = CourseRunCertificateFactory.create(user=user, course_run=course_run)
cert.save()
generate_program_cert_mock.assert_not_called()
mocked_hubspot_contact_sync.assert_called_once()

0 comments on commit 448e8cc

Please sign in to comment.