Files

27 lines
1.4 KiB
Python
Raw Permalink Normal View History

from pathlib import Path
import unittest
ROOT = Path(__file__).parents[2]
class MatchmakerServiceConfirmationContractTest(unittest.TestCase):
def test_backend_exposes_user_confirmation_and_writes_in_service(self):
controller = (ROOT / "backend/src/main/java/com/danyang/match/platform/matchmaker/controller/MatchmakerController.java").read_text(encoding="utf-8")
service = (ROOT / "backend/src/main/java/com/danyang/match/platform/matchmaker/service/MatchmakerService.java").read_text(encoding="utf-8")
mapper = (ROOT / "backend/src/main/java/com/danyang/match/platform/matchmaker/mapper/MatchmakerServiceMapper.java").read_text(encoding="utf-8")
self.assertIn('@PostMapping("/services/{id}/confirm")', controller)
self.assertIn("confirmService(id, principal.id())", controller)
self.assertIn("confirmWaitingForUser", mapper)
def test_progress_page_only_offers_confirmation_for_waiting_user(self):
source = (ROOT / "miniapp/pages/matchmaker-progress/matchmaker-progress.js").read_text(encoding="utf-8")
wxml = (ROOT / "miniapp/pages/matchmaker-progress/matchmaker-progress.wxml").read_text(encoding="utf-8")
self.assertIn("confirmService", source)
self.assertIn("this.data.service.status !== 'waiting_user'", source)
self.assertIn("bindtap=\"onConfirmService\"", wxml)
if __name__ == "__main__":
unittest.main()