示例#1
0
 def timerEvent(self, event):
     from test import login
     a = login()
     if a:
         self.killTimer(self.timer)
         self.hide()
     else:
         self.counter += 1
         self.update()
     if self.counter == 5:
         self.killTimer(self.timer)
         self.hide()
 def setUp(self):
     self.app = app.test_client()
     login(self.app)
示例#3
0
    def service_client(self, new_socket):
        """为这个客户端返回数据"""

        # 1. 接收浏览器发送过来的请求 ,即http请求
        # GET / HTTP/1.1
        # .....
        request = new_socket.recv(1024).decode("utf-8")
        # print(">>>"*50)
        # print(request)

        request_lines = request.splitlines()
        print("")
        print(">" * 20)
        print(request_lines)

        # GET /index.html HTTP/1.1
        # get post put del
        file_name = ""
        ret = re.match(r"[^/]+(/[^ ]*)", request_lines[0])
        if ret:
            file_name = ret.group(1)
            # print("*"*50, file_name)
            if file_name == "/":
                file_name = "/index.html"

        # 2. 返回http格式的数据,给浏览器
        # 如果请求的资源不是.py结尾的就认为是静态资源
        if not file_name.endswith(".py"):
            try:
                f = open("../html" + file_name, "rb")
            except:
                response = "HTTP/1.1 404 NOT FOUND\r\n"
                response += "\r\n"
                response += "------file not found-----"
                new_socket.send(response.encode("utf-8"))
            else:
                html_content = f.read()
                f.close()
                # 2.1 准备发送给浏览器的数据---header
                response = "HTTP/1.1 200 OK\r\n"
                response += "\r\n"
                # 2.2 准备发送给浏览器的数据---boy
                # response += "hahahhah"

                # 将response header发送给浏览器
                new_socket.send(response.encode("utf-8"))
                # 将response body发送给浏览器
                new_socket.send(html_content)
        else:
            # 如果是已.py结尾那么就认为是动态请求
            header = "HTTP/1.1 200 OK\r\n"
            header += "\r\n"

            #body="江姗姗哟%s"%time.ctime()
            body = test.login()

            response = header + body

            new_socket.send(response.encode("utf-8"))

        # 关闭套接
        new_socket.close()
示例#4
0
import test as a
id = input('아이디를 입력하시오 : ')

a.login(id)
示例#5
0
 def test_post_login_invalid_credentials(self):
     username = '******'
     password = '******'
     res = login(self.app, username, password)
     self.assertTrue(res.status_code == 200)
     self.assertTrue('error-message' in res.data)
示例#6
0
 def test_post_login(self):
     res = login(self.app)
     self.assertTrue(res.status_code == 200)
     self.assertTrue('error-message' not in res.data)
     self.assertTrue('Budgeter Dashboard' in res.data)