fromdjango.contrib.auth.modelsimportUserfromlettuceimportstep,worldfromnotification_prefsimportNOTIFICATION_PREF_KEYfromuser_api.modelsimportUserPreferenceUSERNAME="robot"UNSUB_TOKEN="av9E-14sAP1bVBRCPbrTHQ=="@step(u"I have notifications enabled")defenable_notifications(step_):user=User.objects.get(username=USERNAME)UserPreference.objects.create(user=user,key=NOTIFICATION_PREF_KEY,value=UNSUB_TOKEN)@step(u"I access my unsubscribe url")defaccess_unsubscribe_url(step_):world.visit("/notification_prefs/unsubscribe/{0}/".format(UNSUB_TOKEN))@step(u"my notifications should be disabled")defnotifications_should_be_disabled(step_):user=User.objects.get(username=USERNAME)assertnotUserPreference.objects.filter(user=user,key=NOTIFICATION_PREF_KEY).exists()