# Coverage for tests/e2e/test_kedama.py : 100%

## 38 statements 38 run 0 missing 0 excluded 0 partial

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 -*-

2 from __future__ import annotations

3

4# -- stdlib --

5# -- third party --

6 import gevent

7

8# -- own --

9 from .mock import Environ, EventTap

10

11

12# -- code --

13 class GameEnded(Exception):

14 pass

15

16

17 def wait():

18 gevent.idle(-100)

19 gevent.sleep(0.01)

20 gevent.idle(-100)

21

22

23 class TestKedama(object):

24 def testKedama(self):

25 env = Environ()

26 t = EventTap()

27

28 _ = env.server_core()

29 proton = env.client_core()

30 kedama = env.client_core()

31 t.tap(proton, kedama)

32

33 proton.auth.login("Proton")

34 kedama.auth.login("")

35 wait()

36

37 # Kedama should not create modes not allowed

38 assert proton.auth.uid == 2

39 assert kedama.auth.uid < 0

40 kedama.room.create('Boom', 'THBattle2v2', {})

41 wait()

42 assert kedama.events.game_joined not in t

43 assert t.take(kedama.events.server_error) == 'kedama_limitation'

44

45 # Kedama should not join modes not allowed

46 proton.room.create('Meh', 'THBattle2v2', {}); wait()

47 g = t.take(proton.events.game_joined)

48 gid = proton.game.gid_of(g)

49 kedama.room.join(gid); wait()

50 assert kedama.events.game_joined not in t

51 assert t.take(kedama.events.server_error) == 'kedama_limitation'

52

53 # Kedama can create modes allowed, but can't invite

54 proton.room.leave()

55 kedama.room.create('Meh', 'THBattleKOF', {}); wait()

56 g = t.take(kedama.events.game_joined)

57 gid = kedama.game.gid_of(g)

58 kedama.room.invite(proton.auth.uid); wait()

59 assert t.take(kedama.events.server_error) == 'kedama_limitation'