Ejemplo n.º 1
0
    def test_all(self):
        l = users.all()
        self.assertEquals(len(l), 0) # should not be any users

        users.create("gideon", "secret", "*****@*****.**")
        l = users.all()
        self.assertEquals(len(l), 1) # should be 1 user

        users.create("rynge", "secret", "*****@*****.**")
        l = users.all()
        self.assertEquals(len(l), 2) # should be 2 users
Ejemplo n.º 2
0
    def run(self):
        if len(self.args) < 2:
            self.parser.error("Specify USERNAME and EMAIL")
        elif len(self.args) > 2:
            self.parser.error("Invalid argument")

        username = self.args[0]
        email = self.args[1]
        password = self.options.password

        try:
            users.create(username, password, email)
            db.session.commit()
        except Exception, e:
            if self.options.debug: raise
            print e
            exit(1)
Ejemplo n.º 3
0
    def test_getuser(self):
        gideon = users.create("gideon", "secret", "*****@*****.**")

        g2 = users.getuser("gideon")
        self.assertEquals(gideon.username, g2.username)
        self.assertEquals(gideon.hashpass, g2.hashpass)
        self.assertEquals(gideon.email, g2.email)

        self.assertRaises(users.NoSuchUser, users.getuser, "rynge")
Ejemplo n.º 4
0
    def test_passwd(self):
        gideon = users.create("gideon", "secret", "*****@*****.**")
        self.assertTrue(gideon.password_matches("secret")) # original passwd

        users.passwd("gideon", "newsecret")
        self.assertTrue(gideon.password_matches("newsecret")) # new passwd

        gideon2 = users.getuser("gideon")
        self.assertTrue(gideon2.password_matches("newsecret")) # new passwd
Ejemplo n.º 5
0
    def run(self):
        if len(self.args) < 2:
            self.parser.error("Specify USERNAME and EMAIL")
        elif len(self.args) > 2:
            self.parser.error("Invalid argument")

        username = self.args[0]
        email = self.args[1]
        password = self.options.password

        try:
            users.create(username, password, email)
            db.session.commit()
        except Exception, e:
            if self.options.debug:
                raise
            print e
            exit(1)
Ejemplo n.º 6
0
    def setUp(self):
        DBTestCase.setUp(self)

        # Create a test user
        self.username = "******"
        self.password = "******"
        self.email = "*****@*****.**"
        self.user = users.create(username=self.username,
                                 password=self.password,
                                 email=self.email)
        self.user_id = self.user.id
        db.session.commit()
Ejemplo n.º 7
0
    def test_usercreate(self):
        # Make sure we can insert a new user
        u1 = users.create(username="******", password="******", email="*****@*****.**")

        # Make sure one user exists
        self.assertEquals(User.query.count(), 1)

        # Make sure the user matches what we specified
        u2 = User.query.first()
        self.assertEquals(u1.username, u2.username)
        self.assertEquals(u1.hashpass, u2.hashpass)
        self.assertEquals(u1.email, u2.email)
Ejemplo n.º 8
0
 def test_relationship(self):
     u = users.create(username="******", password="******", email="*****@*****.**")
     c = catalogs.save_catalog("replica", u.id, "rc.txt", "regex", StringIO("replica"))
     self.assertEquals(c.user.username, "scott")
Ejemplo n.º 9
0
    def test_usermod(self):
        gideon = users.create("gideon", "secret", "*****@*****.**")
        self.assertEquals(gideon.email, "*****@*****.**") # original email

        users.usermod("gideon", "*****@*****.**")
        self.assertEquals(gideon.email, "*****@*****.**") # new email
Ejemplo n.º 10
0
 def test_userdupes(self):
     users.create(username="******", password="******", email="*****@*****.**")
     self.assertRaises(users.UserExists, users.create, "gideon", "private", "*****@*****.**")