Example #1
0
    def test_unset_option(self):
        """
        The unset_option() function should remove all definitions of an option
        """
        def check_option(user=None):
            CustomOption.objects.get(name='opt', value='val', user=user)

        set_option('opt', 'val')
        unset_option('opt')
        self.assertRaises(CustomOption.DoesNotExist, check_option)

        set_option('opt', 'val', self.user)
        unset_option('opt', self.user)
        self.assertRaises(CustomOption.DoesNotExist, check_option)
Example #2
0
 def test_unset_option(self):
     option = CustomOption(name='opt', value='val')
     option.save()
     unset_option('opt')
     try:
         option = CustomOption.objects.get(name='opt', value='val')
     except CustomOption.DoesNotExist:
         option = None
     self.assertEqual(option, None)
     
     option = CustomOption(name='opt', value='val', user=self.user)
     option.save()
     unset_option('opt', self.user)
     try:
         option = CustomOption.objects.get(name='opt', value='val',
             user=self.user)
     except CustomOption.DoesNotExist:
         option = None
     self.assertEqual(option, None)
Example #3
0
 def test_set_and_get_option(self):
     set_option('opt', 'val')
     value = get_option('opt', 'wrong value')
     self.assertEqual(value, 'val')
     unset_option('opt')