Example #1
0
    def testTooYoungClient(self):
        f = self.__copyFixture()
        f['birth_date'] = "%d-01-01" % datetime.date.today().year
        # Must raise exception
        with self.assertRaises(ValidationError) as cm:
            up = UserProfile(**f)
            up.full_clean()

        err = cm.exception
        self.assertIn(_(u"You must be min"), err.messages[0])
Example #2
0
    def testTooYoungClient(self):
        f = self.__copyFixture()
        f['birth_date'] = "%d-01-01" % datetime.date.today().year
        # Must raise exception
        with self.assertRaises(ValidationError) as cm:
            up = UserProfile(**f)
            up.full_clean()

        err = cm.exception
        self.assertIn(_(u"You must be min"), err.messages[0])
Example #3
0
    def testInvalidPostalAddresses(self):
        for field in ['postal_address', 'delivery_address']:
            f = self.__copyFixture()
            f[field].address = ""
            # Must raise exception
            with self.assertRaises(ValidationError) as cm:
                up = UserProfile(**f)
                up.full_clean()

            err = cm.exception
            self.assertIn(_(u"This field cannot be blank"), err.messages[0])
Example #4
0
    def testInvalidPostalAddresses(self):
        for field in ['postal_address', 'delivery_address']:
            f = self.__copyFixture()
            f[field].address = ""
            # Must raise exception
            with self.assertRaises(ValidationError) as cm:
                up = UserProfile(**f)
                up.full_clean()

            err = cm.exception
            self.assertIn(_(u"This field cannot be blank"), err.messages[0])
Example #5
0
    def test_create_profile_with_fields(self):
        profile_picture = "1.img"
        balance = 20.00
        sales_or_purchase = 2
        is_restaurant = True
        user = User.objects.create()
        profile = UserProfile(profile_picture=profile_picture,
                              balance=balance,
                              sales_or_purchase=sales_or_purchase,
                              is_restaurant=is_restaurant,
                              user=user)

        profile.full_clean()
        profile.save()