Emit events for language proficiencies from the update_account_settings method.

This commit is contained in:
cahrens
2015-04-16 11:53:23 -04:00
committed by Andy Armstrong
parent 97c43adaa4
commit 4797a74e5c
5 changed files with 75 additions and 8 deletions

View File

@@ -1671,6 +1671,13 @@ class EntranceExamConfiguration(models.Model):
class LanguageProficiency(models.Model):
"""
Represents a user's language proficiency.
Note that we have not found a way to emit analytics change events by using signals directly on this
model or on UserProfile. Therefore if you are changing LanguageProficiency values, it is important
to go through the accounts API (AccountsView) defined in
/edx-platform/openedx/core/djangoapps/user_api/accounts/views.py or the AccountLegacyProfileSerializer
in /edx-platform/openedx/core/djangoapps/user_api/accounts/serializers.py so that the events are
emitted.
"""
class Meta:
unique_together = (('code', 'user_profile'),)

View File

@@ -46,14 +46,14 @@ class AccountSettingsTestMixin(EventsTestMixin, WebAppTest):
self.USER_SETTINGS_CHANGED_EVENT_NAME, self.start_time, self.user_id, num_times, setting=setting
)
def verify_settings_changed_events(self, events):
def verify_settings_changed_events(self, events, table=None):
"""
Verify a particular set of account settings change events were fired.
"""
expected_referers = [self.ACCOUNT_SETTINGS_REFERER] * len(events)
for event in events:
event[u'user_id'] = long(self.user_id)
event[u'table'] = u"auth_userprofile"
event[u'table'] = u"auth_userprofile" if table is None else table
self.verify_events_of_type(self.USER_SETTINGS_CHANGED_EVENT_NAME, events, expected_referers=expected_referers)
@@ -424,6 +424,20 @@ class AccountSettingsPageTest(AccountSettingsTestMixin, WebAppTest):
[u'Pushto', u''],
)
self.verify_settings_changed_events(
[{
u"setting": u"language_proficiencies",
u"old": [],
u"new": [{u"code": u"ps"}],
},
{
u"setting": u"language_proficiencies",
u"old": [{u"code": u"ps"}],
u"new": [],
}],
table=u"student_languageproficiency"
)
def test_connected_accounts(self):
"""
Test that fields for third party auth providers exist.