Ejemplo n.º 1
0
 def test_delete_lobby_player(self):
     l = Lobby('Lobby', self.admin, 'test', 'test', 'test', 'test')
     t = Team('Red')
     p = Player('0')
     t.append_player(p)
     l.teams.append(t)
     db.session.add(p)
     db.session.add(l)
     db.session.commit()
     resp = self.client.delete('/admin/rest/lobbies/%d/teams/0/players/%d' %
         (l.id, p.id))
     self.assertStatus(resp, 200)
     l = db.session.merge(l)
     self.assertEqual(len(l.teams[0].players), 0)
Ejemplo n.º 2
0
 def test_get_lobby_player_listing(self, magic_get_summary):
     l = Lobby('A', self.admin, '', '', '', '')
     t = Team('Red')
     p = Player('0')
     t.append_player(self.admin)
     t.append_player(p)
     l.teams.append(t)
     db.session.add(l)
     db.session.commit()
     magic_get_summary.return_value = {'personaname':'Anonymous'}
     resp = self.client.get('/admin/rest/lobbies/%d/teams/0/players' % l.id)
     self.assertTrue('lobby_players' in resp.json)
     l_players = resp.json['lobby_players']
     self.assertEqual(len(l_players), 2)
Ejemplo n.º 3
0
 def test_get_lobby_player(self, magic_get_summary):
     l = Lobby('A', self.admin, '', '', '', '')
     t = Team('Red')
     t.append_player(self.admin)
     l.teams.append(t)
     db.session.add(l)
     db.session.commit()
     magic_get_summary.return_value = {'personaname':'Anonymous'}
     resp = self.client.get('/admin/rest/lobbies/%d/teams/0/players/%d' %
             (l.id, self.admin.id))
     self.assertTrue('lobby_player' in resp.json)
     player = resp.json['lobby_player']
     self.assertTrue('player' in player)
     self.assertTrue('class_id' in player)
     self.assertTrue('ready' in player)
Ejemplo n.º 4
0
 def test_on_set_lobby_name(self, magic_make, magic_item_make, magic_broadcast):
     instance = self._makeOne()
     o = Player('')
     l = Lobby('', o, '', '', '', '')
     t = Team('Red')
     l.teams.append(t)
     p = Player('0')
     t.append_player(p)
     db.session.add(o)
     db.session.add(l)
     db.session.add(t)
     db.session.add(p)
     db.session.commit()
     instance.lobby_id = l.id
     g.player = o
     instance.on_set_lobby_name('test')
     l = db.session.merge(l)
     self.assertEqual(l.name, 'test')
Ejemplo n.º 5
0
 def test_on_toggle_ready(self, magic_make, magic_broadcast):
     instance = self._makeOne()
     o = Player('')
     l = Lobby('', o, '', '', '', '')
     t = Team('Red')
     l.teams.append(t)
     p = Player('0')
     t.append_player(p)
     db.session.add(o)
     db.session.add(l)
     db.session.add(t)
     db.session.add(p)
     db.session.commit()
     instance.lobby_id = l.id
     g.player = p
     instance.allowed_methods = set(['on_leave',
         'recv_connect', 'on_set_team', 'on_set_class', 'on_toggle_ready'])
     instance.on_toggle_ready()
     self.assertEqual(instance.allowed_methods, set(['on_leave',
         'recv_connect', 'on_toggle_ready']))
     self.assertTrue(l.teams[0].players[0].ready)