Beispiel #1
0
def addMoney():
    User.setAccount(Utils.inputHelp("账号"))
    Bank.setMoney(Utils.inputHelp("存储金额"))

    start = Bank.bank_addMoney(User.getAccount(), Bank.getMoney())
    if start == 1:
        print("存入成功!")
    if start == False:
        print("您输入的账号不存在!")
Beispiel #2
0
class TestAddUser(unittest.TestCase):
    user = None
    address = None
    bank = None

    def setUp(self) -> None:
        self.user = User()
        self.address = Address()
        self.bank = Bank()

    def test_adduser1(self):
        # 1.准备测试数据
        self.user.setAccount("qqqqqqq1")
        self.user.setPassword("123456")
        self.user.setUsername("q1")
        self.address.setCounrry("中国")
        self.address.setProvince("北京")
        self.address.setStreet("幸福路")
        self.address.setDoor("46")

        # 2. 预期结果
        teststart = 1

        # 3.调用被测方法
        start = self.bank.bank_addUser(self.user.getAccount(),
                                       self.user.getUsername(),
                                       self.user.getPassword(),
                                       self.address.getCounrry(),
                                       self.address.getProvicne(),
                                       self.address.getStreet(),
                                       self.address.getDoor())

        # 4.断言
        self.assertEqual(teststart, start)

    def test_adduser2(self):
        # 1.准备测试数据
        self.user.setAccount("0tqr0d3c")
        self.user.setPassword("123456")
        self.user.setUsername("q1")
        self.address.setCounrry("中国")
        self.address.setProvince("北京")
        self.address.setStreet("幸福路")
        self.address.setDoor("46")

        # 2. 预期结果
        teststart = 2

        start = self.bank.bank_addUser(self.user.getAccount(),
                                       self.user.getUsername(),
                                       self.user.getPassword(),
                                       self.address.getCounrry(),
                                       self.address.getProvicne(),
                                       self.address.getStreet(),
                                       self.address.getDoor())
        # 3.断言
        self.assertEqual(teststart, start)
Beispiel #3
0
def withdrawal():
    User.setAccount(Utils.inputHelp("账号"))
    User.setPassword(Utils.inputHelp("密码"))
    Bank.setMoney(Utils.inputHelp("要取出的金额"))

    start = Bank.bank_withdrawal(User.getAccount(), User.getPassword(),
                                 Bank.getMoney())
    if start == 0:
        print("取款成功!")
    if start == 1:
        print("账号不存在!")
    if start == 2:
        print("密码不对")
    if start == 3:
        print("账户余额不足")
Beispiel #4
0
def seek():
    User.setAccount(Utils.inputHelp("您的要查询的账号"))
    User.setPassword(Utils.inputHelp("密码"))

    start = Bank.bank_seek(User.getAccount(), User.getPassword())
    if start == 0:
        # 查询表中数据
        sql = "select * from jdbcbank where account = %s and password = %s"
        param = [User.getAccount(), User.getPassword()]
        # 执行sql
        data = DB.Select(sql, param)
        for i in data:
            account = data[0][0]
            username = data[0][1]
            password = data[0][2]
            cunrry = data[0][3]
            province = data[0][4]
            street = data[0][5]
            door = data[0][6]
            money = data[0][7]
            bank_name = data[0][8]
        print("以下为您的账号信息")
        info = '''
                ----------- 个人信息-------------
                账号: %s,
                用户名: %s,
                取款密码: %s,
                地址信息: 
                        国家: %s,
                        省份: %s,
                        街道: %s,
                        门牌号: %s,
                余额: %s,
                开户行: %s
                ---------------------------------
                '''
        print(info % (account, username, password, cunrry, province, street,
                      door, money, bank_name))
    if start == 1:
        print("该用户不存在")
    if start == 2:
        print("您输入的密码不正确")
Beispiel #5
0
class TestAddMoney(unittest.TestCase):
    user = None
    address = None
    bank = None

    def setUp(self) -> None:
        self.user = User()
        self.bank = Bank()
        self.address = Address()

    def test_addMoney1(self):
        # 1.准备测试数据
        self.user.setAccount("qqqqqqq2")
        self.bank.setMoney("10000")

        # 2.预期结果
        teststart = 1

        # 3.调用被测方法
        start = self.bank.bank_addMoney(self.user.getAccount(),
                                        self.bank.getMoney())

        # 4.断言
        self.assertEqual(teststart, start)

    def test_addMoney2(self):
        # 1.准备测试数据
        self.user.setAccount("qqqqqqq3")
        self.bank.setMoney("10000")

        # 2.预期结果
        teststart = False

        # 3.调用被测方法
        start = self.bank.bank_addMoney(self.user.getAccount(),
                                        self.bank.getMoney())

        # 4.断言
        self.assertEqual(teststart, start)
Beispiel #6
0
class TestSeek(unittest.TestCase):
    user = None
    bank = None

    def setUp(self) -> None:
        self.user = User()
        self.bank = Bank()

    def test_seek1(self):
        self.user.setAccount("qqqqqq14")
        self.user.setPassword("123456")

        teststart = 0

        start = self.bank.bank_seek(self.user.getAccount(),
                                    self.user.getPassword())

        self.assertEqual(teststart, start)

    def test_seek2(self):
        self.user.setAccount("qqqqqq15")
        self.user.setPassword("123456")

        teststart = 1

        start = self.bank.bank_seek(self.user.getAccount(),
                                    self.user.getPassword())

        self.assertEqual(teststart, start)

    def test_seek3(self):
        self.user.setAccount("qqqqqq16")
        self.user.setPassword("weqweqw")

        teststart = 2

        start = self.bank.bank_seek(self.user.getAccount(),
                                    self.user.getPassword())

        self.assertEqual(teststart, start)
Beispiel #7
0
class TestWithdrawal(unittest.TestCase):
    user = None
    bank = None

    def setUp(self) -> None:
        self.user = User()
        self.bank = Bank()

    def test_Withdrawal1(self):
        # 1.准备数据
        self.user.setAccount("qqqqqqq4")
        self.user.setPassword("123456")
        self.bank.setMoney("100")

        # 2.预期结果
        teststart = 0

        # 3.调用被测试方法
        start = self.bank.bank_withdrawal(self.user.getAccount(),
                                          self.user.getPassword(),
                                          self.bank.getMoney())

        # 4.断言
        self.assertEqual(teststart, start)

    def test_Withdrawal2(self):
        # 1.准备数据
        self.user.setAccount("qqqqqqq5")
        self.user.setPassword("123456")
        self.bank.setMoney("100")

        # 2.预期结果
        teststart = 1

        # 3.调用被测试方法
        start = self.bank.bank_withdrawal(self.user.getAccount(),
                                          self.user.getPassword(),
                                          self.bank.getMoney())

        # 4.断言
        self.assertEqual(teststart, start)

    def test_Withdrawal3(self):
        # 1.准备数据
        self.user.setAccount("qqqqqqq6")
        self.user.setPassword("333333")
        self.bank.setMoney("100")

        # 2.预期结果
        teststart = 2

        # 3.调用被测试方法
        start = self.bank.bank_withdrawal(self.user.getAccount(),
                                          self.user.getPassword(),
                                          self.bank.getMoney())

        # 4.断言
        self.assertEqual(teststart, start)

    def test_Withdrawal4(self):
        # 1.准备数据
        self.user.setAccount("qqqqqqq7")
        self.user.setPassword("123456")
        self.bank.setMoney("100")

        # 2.预期结果
        teststart = 3

        # 3.调用被测试方法
        start = self.bank.bank_withdrawal(self.user.getAccount(),
                                          self.user.getPassword(),
                                          self.bank.getMoney())

        # 4.断言
        self.assertEqual(teststart, start)