Beispiel #1
0
    def testDeleteAccount(self):
        acc = Account(user="******", passwd="passwd", email="email")
        acc.save()
        acc = Account.fetch(user="******")
        assert acc.user == "user"

        acc.delete()
        acc = Account.fetch(user="******")
        assert acc is None
Beispiel #2
0
    def testCreateAccount(self):
        self.assertRaises(TypeError, Account, user="******")
        self.assertRaises(TypeError, Account, passwd="passwd")
        acc = Account(user="******", passwd="passwd", email="email")
        acc.save()

        print "Acc made:", acc
        acc = Account.fetch(user="******")
        assert acc is None
        acc = Account.fetch(user="******")
        assert acc.user == "user"
        acc = Account.fetch(email="bar")
        assert acc is None
        acc = Account.fetch(email="email")
        assert acc.email == "email"
Beispiel #3
0
    def testFetchAccount(self):
        # Hey, this test is redundant(!) with the previous, but I can't
        # decide what to test where, is this coupeled enough to
        # merge?

        acc = Account(user="******", passwd="passwd", email="email")
        acc.save()

        acc = Account.fetch(user="******")
        assert acc is None
        acc = Account.fetch(user="******")
        assert acc.user == "user"
        acc = Account.fetch(email="bar")
        assert acc is None
        acc = Account.fetch(email="email")
        assert acc.email == "email"
Beispiel #4
0
    def testModifyAccount(self):
        # You'r allowed to change passwd & e-mail
        # But not your username!
        acc = Account(user="******", passwd="passwd", email="email")
        acc.save()
        acc = Account.fetch(user="******")
        assert acc.user == "user"

        acc.user = "******"
        self.assertRaises(TypeError, acc.save)

        acc = Account.fetch(user="******")
        assert acc.user == "user"
        assert acc.passwd == "passwd"
        assert acc.email == "email"
        acc.passwd = "newpass"
        acc.email = "newmail"
        acc.save()

        acc = None
        acc = Account.fetch(user="******")
        assert acc.user == "user"
        assert acc.passwd == "newpass"
        assert acc.email == "newmail"