Exemplo n.º 1
0
 def test_updatepassword2(self):
     a = User(username="******", password="******", name="ray", detail="")
     b = User(username="******", password="******", name="ray", detail="")
     s = [a, b]
     user_db.insert_users_table(s)
     self.assertTrue(
         user_db.update_user_password(1, "ssssdskkkdjjdnvnkskd11s"))
Exemplo n.º 2
0
 def test_selectpassword2(self):
     a = User(username="******", password="******", name="ray", detail="")
     b = User(username="******", password="******", name="ray", detail="")
     s = [a, b]
     user_db.insert_users_table(s)
     self.assertEqual(user_db.select_password("2ry", "ssss"), None)
     self.assertEqual(user_db.select_password("1ra", "ssss"), None)
Exemplo n.º 3
0
 def test_update2(self):
     a = User(username="******", password="******", name="ray", detail="")
     b = User(username="******", password="******", name="ray", detail="")
     s = [a, b]
     user_db.insert_users_table(s)
     c = User(username="******", password="******", name="rdsday", detail="13132")
     self.assertTrue(user_db.update_user_table(9, c))
Exemplo n.º 4
0
 def test_user(self):
     a = User(username="******", password="******", name="ray", detail="")
     b = User(username="******", password="******", name="ray", detail="")
     s = [a, b]
     c = User(username="******",
              password="******",
              name="ray",
              detail="1);DROP TABLE if exists USER--")
     self.assertTrue(user_db.insert_users_table(s))
     self.assertTrue(user_db.insert_user_table(c))
     user_db.drop_user_table()
     user_db.init_user_table()
     s.append(c)
     self.assertTrue(user_db.insert_users_table(s))
     self.assertFalse(
         user_db.delete_user_table2("1);DROP TABLE if exists USER--"))
     self.assertTrue(user_db.update_user_table(1, c))
     self.assertEqual(
         user_db.select_user_name("1ray);DROP TABLE if exists USER--"),
         None)
     self.assertEqual(
         user_db.select_password("1ray",
                                 "sss);DROP TABLE if exists USER--"), None)
     self.assertEqual(
         user_db.select_user("1ray", "sss);DROP TABLE if exists USER--"),
         None)
Exemplo n.º 5
0
 def test_insertmany3(self):
     a = User(username="******", password="******", name="ray", detail="")
     b = User(username="******",
              password="******",
              name="ray",
              detail="")
     s = [a, b]
     self.assertTrue(user_db.insert_users_table(s))
Exemplo n.º 6
0
 def test_updatepassword3(self):
     a = User(username="******", password="******", name="ray", detail="")
     b = User(username="******", password="******", name="ray", detail="")
     s = [a, b]
     user_db.insert_users_table(s)
     self.assertFalse(user_db.update_user_password(None, "ss"))
     self.assertFalse(user_db.update_user_password(1, None))
     self.assertFalse(user_db.update_user_password(None, None))
Exemplo n.º 7
0
 def test_update3(self):
     a = User(username="******", password="******", name="ray", detail="")
     b = User(username="******", password="******", name="ray", detail="")
     s = [a, b]
     user_db.insert_users_table(s)
     c = User(username="******", password="******", name="rdsday", detail="13132")
     self.assertFalse(user_db.update_user_table(None, None))
     self.assertFalse(user_db.update_user_table(1, None))
     self.assertFalse(user_db.update_user_table(None, c))
Exemplo n.º 8
0
    def select_user(username, password):
        if username == None or password == None:
            return None

        sql = "SELECT * FROM USER WHERE user_name=%s AND password=%s;"

        conn = set_conect()
        cursor = conn.cursor()
        try:
            cursor.execute(sql, (username, password))
            conn.commit()
            result = cursor.fetchone()
            user = User(username=result[1],
                        password=result[2],
                        detail=result[3],
                        name=result[4])

        except:
            print("select_password error")
            return None
        finally:
            cursor.close()
            conn.close()

        return user
Exemplo n.º 9
0
 def test_deleteid2(self):
     a = User(username="******", password="******", name="ray", detail="")
     b = User(username="******", password="******", name="ray", detail="")
     s = [a, b]
     user_db.insert_users_table(s)
     self.assertTrue(user_db.delete_user_table2(10))
Exemplo n.º 10
0
 def test_insert2(self):
     a = User(username="******",
              password="******",
              name="ray",
              detail="")
     self.assertFalse(user_db.insert_user_table(a))
Exemplo n.º 11
0
 def test_selectuser1(self):
     a = User(username="******", password="******", name="ray", detail="")
     b = User(username="******", password="******", name="ray", detail="")
     s = [a, b]
     user_db.insert_users_table(s)
     self.assertEqual(user_db.select_user("1ray", "sss").username, "1ray")
Exemplo n.º 12
0
 def test_insert1(self):
     a = User(username="******", password="******", name="ray", detail="")
     self.assertTrue(user_db.insert_user_table(a))
Exemplo n.º 13
0
    def test_insertmany6(self):
        a = User(username="******", password="******", name="ray", detail="")
        b = None
        s = [a, b]

        self.assertFalse(user_db.insert_users_table(s))
Exemplo n.º 14
0
def inituser():
    user_db.drop_user_table()
    user_db.init_user_table()
    user_db.insert_user_table(
        User(username="******", password="******", name="ray", detail=""))