コード例 #1
0
    def test_change_name_no_args(self):
        self.ad1 = models.User()
        self.ad1.email = "*****@*****.**"
        self.ad1.password = "******"
        self.ad1.type = "administrator"
        self.ad1.save()

        with self.assertRaises(TypeError):
            Commands.change_password()
コード例 #2
0
    def post(request):
        request.session.set_expiry(300)
        email = request.POST["email"]
        password = request.POST["password"]
        name = request.POST["name"]
        phone = request.POST["phone"]
        address = request.POST["address"]
        pick_anything = False

        if email != "":
            pick_anything = True
            response = Commands.change_email(request.session["email"], email)
            if response == "Email address changed.":
                messages.success(request, response)
                request.session["email"] = email
            else:
                messages.error(request, response)

        if password != "":
            pick_anything = True
            response = Commands.change_password(request.session["email"],
                                                password)

            if response == "Password changed.":
                messages.success(request, response)
            else:
                messages.error(request, response)

        if name != "":
            pick_anything = True
            response = Commands.change_name(request.session["email"], name)

            if response == "Name changed.":
                messages.success(request, response)
            else:
                messages.error(request, response)

        if phone != "":
            pick_anything = True
            response = Commands.change_phone(request.session["email"], phone)

            if response == "Phone number changed.":
                messages.success(request, response)
            else:
                messages.error(request, response)

        if address != "":
            pick_anything = True
            response = Commands.change_address(request.session["email"],
                                               address)

            if response == "Address changed.":
                messages.success(request, response)
            else:
                messages.error(request, response)

        if not pick_anything:
            messages.error(request, "You should pick something to change.")

        return redirect("EditInfo1")
コード例 #3
0
 def test_change_min_password(self):
     self.ad1 = models.User()
     self.ad1.email = "*****@*****.**"
     self.ad1.password = "******"
     self.ad1.type = "administrator"
     self.ad1.save()
     self.assertEquals(Commands.change_password("*****@*****.**", "1"),
                       "Password changed.")
     self.ad1 = models.User.objects.get(email="*****@*****.**")
     self.assertEquals(self.ad1.password, "1")
     self.assertNotEquals(self.ad1.password, "password")
コード例 #4
0
 def test_change_ta_password(self):
     self.ta1 = models.User()
     self.ta1.email = "*****@*****.**"
     self.ta1.password = "******"
     self.ta1.type = "instructor"
     self.ta1.save()
     self.assertEquals(
         Commands.change_password("*****@*****.**", "new_password"),
         "Password changed.")
     ta1 = models.User.objects.get(email="*****@*****.**")
     self.assertEquals(ta1.password, "new_password")
     self.assertNotEquals(ta1.password, "password")
コード例 #5
0
 def test_change_super_password(self):
     self.sup1 = models.User()
     self.sup1.email = "*****@*****.**"
     self.sup1.password = "******"
     self.sup1.type = "supervisor"
     self.sup1.save()
     self.assertEquals(
         Commands.change_password("*****@*****.**", "new_password"),
         "Password changed.")
     sup1 = models.User.objects.get(email="*****@*****.**")
     self.assertEquals(sup1.password, "new_password")
     self.assertNotEquals(sup1.password, "password")
コード例 #6
0
 def test_change_password_too_big(self):
     self.ad1 = models.User()
     self.ad1.email = "*****@*****.**"
     self.ad1.password = "******"
     self.ad1.type = "administrator"
     self.ad1.save()
     self.assertEquals(
         Commands.change_password("*****@*****.**",
                                  "bigol20charpassword11"),
         "Password must be 20 characters or less.")
     self.ad1 = models.User.objects.get(email="*****@*****.**")
     self.assertEquals(self.ad1.password, "password")
     self.assertNotEquals(self.ad1.password, "bigol20charpassword11")