Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# -*- coding: utf-8 -*- 

2from __future__ import annotations 

3 

4# -- stdlib -- 

5# -- third party -- 

6import gevent 

7 

8# -- own -- 

9from .mock import Environ, EventTap 

10 

11 

12# -- code -- 

13class GameEnded(Exception): 

14 pass 

15 

16 

17def wait(): 

18 gevent.idle(-100) 

19 gevent.sleep(0.01) 

20 gevent.idle(-100) 

21 

22 

23class TestMatching(object): 

24 def testMatching(self): 

25 env = Environ() 

26 t = EventTap() 

27 

28 s = env.server_core() 

29 a = env.client_core() 

30 b = env.client_core() 

31 t.tap(a, b) 

32 

33 a.auth.login("Alice") 

34 b.auth.login("Bob") 

35 wait() 

36 

37 # Can setup matching 

38 a.matching.start(['THBattleKOF']) 

39 a.matching.stop() 

40 b.matching.start(['THBattleKOF']) 

41 wait() 

42 assert a.events.game_joined not in t 

43 assert s.lobby.state_of(s.lobby.get(a.auth.uid)) == 'lobby' 

44 assert s.lobby.state_of(s.lobby.get(b.auth.uid)) == 'lobby' 

45 a.matching.start(['THBattleKOF']) 

46 wait() 

47 assert a.events.game_joined in t 

48 assert s.lobby.state_of(s.lobby.get(a.auth.uid)) == 'room' 

49 assert s.lobby.state_of(s.lobby.get(b.auth.uid)) == 'room'