Beispiel #1
0
class ShopTestCase(unittest.TestCase):
    def create_fixtures(self):
        self.user = User()
        self.user.username =  "******"
        self.user.password = '******'
        self.user.save()
        self.shop = Shop()
        self.shop.owner = self.user
        self.shop.name = 'myshopname'
        self.shop.save()

    def test_01_create_shop_is_correct(self):
        self.create_fixtures()
        ret = Shop.objects.all()
        self.assertEqual(len(ret), 1)
        self.assertEqual(ret[0].name, 'myshopname')
Beispiel #2
0
 def create_fixtures(self):
     self.user = User()
     self.user.username =  "******"
     self.user.password = '******'
     self.user.save()
     self.shop = Shop()
     self.shop.owner = self.user
     self.shop.name = 'myshopname'
     self.shop.save()
Beispiel #3
0
    def save(self, profile_callback=None):
        """
        This method is overrided from the registrationForm in django-registration.
        It Create the new ``User`` and ``RegistrationProfile``, and
        returns the ``User``.

        This is essentially a light wrapper around
        ``RegistrationProfile.objects.create_inactive_user()``,
        feeding it the form data and a profile callback (see the
        documentation on ``create_inactive_user()`` for details) if
        supplied.

        """
        new_user = RegistrationProfile.objects.create_inactive_user(username=self.cleaned_data['email'],
                                                                    password=self.cleaned_data['password1'],
                                                                    email=self.cleaned_data['email'],
                                                                    profile_callback=profile_callback)
        shop = Shop()
        shop.name = self.cleaned_data['store_name']
        shop.owner = new_user
        shop.save()
        return new_user