def test_約會成功(self): cluster.Male(userId=inspect.currentframe().f_code.co_name, status=110).save() cluster.Female(userId=inspect.currentframe().f_code.co_name + "G", status=110).save() cluster.Date(femaleId=inspect.currentframe().f_code.co_name + "G", maleId=inspect.currentframe().f_code.co_name, status=40).save() dict = {} self.messageRequestDict(dict, "我出發了", inspect.currentframe().f_code.co_name) response = self.client.post('/', json=dict) self.assertEqual(response.status_code, 200) self.assertEqual(response.data.decode("utf-8"), "祝您約會順利") t_date = cluster.Member.getDate(inspect.currentframe().f_code.co_name) self.assertEqual(t_date.status, 50) t_memeber = cluster.Member.getUser( inspect.currentframe().f_code.co_name) self.assertEqual(t_memeber.status, 100) t_memeber.delete() t_memeber = cluster.Member.getUser( inspect.currentframe().f_code.co_name + "G") self.assertEqual(t_memeber.status, 100) t_memeber.delete() t_date.delete()
def test_輸入午休時間(self): t_member = t_member = cluster.Female( userId=inspect.currentframe().f_code.co_name, status=110).save() cluster.Date(femaleId=inspect.currentframe().f_code.co_name, status=2).save() dict = {} self.messageRequestDict(dict, "十二點半", inspect.currentframe().f_code.co_name) response = self.client.post('/', json=dict) self.assertEqual(response.status_code, 200) self.assertEqual(response.data.decode("utf-8"), "午休時間很長嗎?") t_date = cluster.Member.getDate(inspect.currentframe().f_code.co_name) self.assertEqual(t_date.status, 3) self.assertEqual(t_date.lunchBreakT, "十二點半") # t_memeber.delete() # def test_輸入午休長度(self): # cluster.Female(userId=inspect.currentframe().f_code.co_name, status=14).save() dict = {} self.messageRequestDict(dict, "普通,一小半", inspect.currentframe().f_code.co_name) response = self.client.post('/', json=dict) self.assertEqual(response.status_code, 200) self.assertEqual(response.data.decode("utf-8"), "喜歡吃韓式還是日式") t_date = cluster.Member.getDate(inspect.currentframe().f_code.co_name) self.assertEqual(t_date.status, 4) self.assertEqual(t_date.lunchBreakL, "一小半") t_date.delete() t_member.delete()
def test_選擇約會對象(self): t_member1 = cluster.Female( userId=inspect.currentframe().f_code.co_name, status=110).save() t_member2 = cluster.Male(userId=inspect.currentframe().f_code.co_name + "M", status=110).save() cluster.Date(femaleId=inspect.currentframe().f_code.co_name, invList=[inspect.currentframe().f_code.co_name + "M"], status=11).save() dict = {} self.postBackRequestDict(dict, inspect.currentframe().f_code.co_name + "M", inspect.currentframe().f_code.co_name) response = self.client.post('/', json=dict) self.assertEqual(response.status_code, 200) self.assertEqual(response.data.decode("utf-8"), "開放 12hr 聊天") t_date = cluster.Member.getDate(inspect.currentframe().f_code.co_name) self.assertEqual(t_date.status, 20) self.assertEqual(t_date.maleId, inspect.currentframe().f_code.co_name + "M") self.assertNotIn(inspect.currentframe().f_code.co_name + "M", t_date.invList) t_date.delete() t_member1.delete() t_member2.delete()
def test_沒有人約(self): t_member = cluster.Female(userId=inspect.currentframe().f_code.co_name, status=110).save() cluster.Date(femaleId=inspect.currentframe().f_code.co_name, status=10).save() dict = {} self.messageRequestDict(dict, "隨便輸入訊息", inspect.currentframe().f_code.co_name) response = self.client.post('/', json=dict) self.assertEqual(response.status_code, 200) self.assertEqual(response.data.decode("utf-8"), "無人邀請") t_date = cluster.Member.getDate(inspect.currentframe().f_code.co_name) self.assertEqual(t_date.status, 10) t_date.delete() t_member.delete()
def test_討論好餐廳和時間了(self): t_member = cluster.Male(userId=inspect.currentframe().f_code.co_name, status=110).save() cluster.Date(femaleId=inspect.currentframe().f_code.co_name + "G", maleId=inspect.currentframe().f_code.co_name, status=20).save() dict = {} self.messageRequestDict(dict, "討論好餐廳和時間了", inspect.currentframe().f_code.co_name) response = self.client.post('/', json=dict) self.assertEqual(response.status_code, 200) self.assertEqual(response.data.decode("utf-8"), "請輸入<inLIne定位資訊>") t_date = cluster.Member.getDate(inspect.currentframe().f_code.co_name) self.assertEqual(t_date.status, 21) t_date.delete() t_member.delete()
def test_選擇希望吃飯地區(self): t_member = t_member = cluster.Female( userId=inspect.currentframe().f_code.co_name, status=110).save() cluster.Date(femaleId=inspect.currentframe().f_code.co_name, status=1).save() dict = {} self.messageRequestDict(dict, "內湖科學園區", inspect.currentframe().f_code.co_name) response = self.client.post('/', json=dict) self.assertEqual(response.status_code, 200) self.assertEqual(response.data.decode("utf-8"), "幾點開始午休呢") t_date = cluster.Member.getDate(inspect.currentframe().f_code.co_name) self.assertEqual(t_date.status, 2) self.assertEqual(t_date.workDist, "內湖科學園區") t_date.delete() t_member.delete()
def test_聊天1(self): t_member = cluster.Male(userId=inspect.currentframe().f_code.co_name, status=110).save() t_date = cluster.Date(femaleId=inspect.currentframe().f_code.co_name + "G", maleId=inspect.currentframe().f_code.co_name, status=20).save() dict = {} self.messageRequestDict(dict, "午安啊~", inspect.currentframe().f_code.co_name) response = self.client.post('/', json=dict) self.assertEqual(response.status_code, 200) t_date = cluster.Member.getDate(inspect.currentframe().f_code.co_name + "G") self.assertEqual(t_date.status, 20) t_date.delete() t_member.delete()
def test_選擇日期(self): t_member = cluster.Female(userId=inspect.currentframe().f_code.co_name, status=110).save() cluster.Date(femaleId=inspect.currentframe().f_code.co_name, status=5).save() dict = {} self.messageRequestDict(dict, "明天", inspect.currentframe().f_code.co_name) response = self.client.post('/', json=dict) self.assertEqual(response.status_code, 200) self.assertEqual(response.data.decode("utf-8"), "成功發起約會") t_date = cluster.Member.getDate(inspect.currentframe().f_code.co_name) self.assertEqual(t_date.status, 10) self.assertEqual(t_date.dateDate, datetime.date.today() + datetime.timedelta(days=1)) t_date.delete() t_member.delete()
def test_敲定時間地點(self): t_member = cluster.Male(userId=inspect.currentframe().f_code.co_name, status=110).save() cluster.Date(femaleId=inspect.currentframe().f_code.co_name + "G", maleId=inspect.currentframe().f_code.co_name, status=21).save() dict = {} self.messageRequestDict( dict, "<" + "https://inline.app/reservations/-MYykIBSxYNLzWg4ZgtI" + ">", inspect.currentframe().f_code.co_name) response = self.client.post('/', json=dict) self.assertEqual(response.status_code, 200) self.assertEqual(response.data.decode("utf-8"), "關閉聊天,約會前12hr會開啟") t_date = cluster.Member.getDate(inspect.currentframe().f_code.co_name) self.assertEqual( t_date.inlineRes, "https://inline.app/reservations/-MYykIBSxYNLzWg4ZgtI") self.assertEqual(t_date.status, 30) t_date.delete() t_member.delete()
def test_約她(self): cluster.Male(userId=inspect.currentframe().f_code.co_name, status=100).save() cluster.Date(femaleId=inspect.currentframe().f_code.co_name + "G", status=10).save() dict = {} self.postBackRequestDict(dict, inspect.currentframe().f_code.co_name + "G", inspect.currentframe().f_code.co_name) response = self.client.post('/', json=dict) self.assertEqual(response.status_code, 200) self.assertEqual(response.data.decode("utf-8"), "成功邀約,對象會在24小時內回覆") t_memeber = cluster.Member.getUser( inspect.currentframe().f_code.co_name) self.assertEqual(t_memeber.status, 110) t_memeber.delete() t_date = cluster.Member.getDate(inspect.currentframe().f_code.co_name + "G") self.assertIn(inspect.currentframe().f_code.co_name, t_date.invList) self.assertEqual(t_date.status, 11) t_date.delete()