def test_remove_signup_from_sequence(self):
        signup_models.create_or_update_signup('*****@*****.**', {
            'q1': 'ar1',
            'q2': 'ar2'
        })
        signup = signup_models.get_signup('*****@*****.**')
        self.assertEquals(signup['sequence'], 1)

        with patch('signup.models.sequence_model.get_current_sequence_number',
                   lambda: 2):
            signup_models.remove_signup_from_sequence('*****@*****.**')

        signup = signup_models.get_signup('*****@*****.**')
        self.assertEquals(signup['sequence'], 2)

        signup_models.create_or_update_signup('*****@*****.**', {
            'q1': 'ar1',
            'q2': 'ar2'
        })
        signup = signup_models.get_signup('*****@*****.**')
        self.assertEquals(signup['sequence'], 1)

        with patch('signup.models.sequence_model.get_current_sequence_number',
                   lambda: None):
            signup_models.remove_signup_from_sequence('*****@*****.**')

        signup = signup_models.get_signup('*****@*****.**')
        self.assertEquals(signup['sequence'], None)
Example #2
0
def unsubscribe_from_sequence( address ):

    # remove from sequence group
    try:
        user_signup = signup_model.get_signup(address)
        sequence_list = sequence_model.sequence_list_name(user_signup['sequence'])
        mailgun_api.remove_list_member(sequence_list, address)
    except:
        log.error(u"couldn't remove {0} from sequence list".format(address))
    
    # remove from small groups
    # TODO: Can a user be subscribed to more than one group or more than one
    # sequence at the same time?
    groups = groups_model.get_member_groups(address)
    for group in groups:
        groups_model.remove_group_member(group['uri'], address)
        groups_model.sync_group_with_mailgun(group['uri'])

    # add signup to next sequence.
    signup_model.remove_signup_from_sequence(address)
Example #3
0
    def test_remove_signup_from_sequence(self):
        signup_models.create_or_update_signup('*****@*****.**', {'q1':'ar1', 'q2':'ar2'})
        signup = signup_models.get_signup('*****@*****.**')
        self.assertEquals(signup['sequence'], 1)

        with patch('signup.models.sequence_model.get_current_sequence_number', lambda: 2):
            signup_models.remove_signup_from_sequence('*****@*****.**')

        signup = signup_models.get_signup('*****@*****.**')
        self.assertEquals(signup['sequence'], 2)

        signup_models.create_or_update_signup('*****@*****.**', {'q1':'ar1', 'q2':'ar2'})
        signup = signup_models.get_signup('*****@*****.**')
        self.assertEquals(signup['sequence'], 1)

        with patch('signup.models.sequence_model.get_current_sequence_number', lambda: None):
            signup_models.remove_signup_from_sequence('*****@*****.**')

        signup = signup_models.get_signup('*****@*****.**')
        self.assertEquals(signup['sequence'], None)