Exemplo n.º 1
0
 def test_add_points_with_many_players(self):
     pointsContainer = PointsContainer()
     pointsContainer.set_players_and_options({
         "Kaj": "Op1",
         "Kaj3": "Op3",
         "Kaj2": "Op2",
     })
     pointsContainer.add_point_by_quote("Op2")
     self.assertEqual(pointsContainer.get_points("Kaj"), 0)
     self.assertEqual(pointsContainer.get_points("Kaj2"), 1)
     self.assertEqual(pointsContainer.get_points("Kaj3"), 0)
Exemplo n.º 2
0
def add_points_by_name():
    if request.method == 'POST':
        """ Example usage:
            curl -d '{"player":"Kaju"}' -X POST http://localhost:5000/draw/rest/addPoints
        """
        # TODO(kaj): Handle correctness of request
        points_container = PointsContainer()
        points_container.set_players_and_options(global_drawer.draw())

        player = request.get_json(force=True)['player']
        points_container.add_point_to_player(player)

        player_points = points_container.get_points(player)

        return json.dumps({"Actual Points": player_points})
    else:
        raise Exception('This template is gone. 405')
Exemplo n.º 3
0
 def test_add_points(self):
     pointsContainer = PointsContainer()
     pointsContainer.set_players_and_options({"Kaj": "Op1"})
     pointsContainer.add_point_to_player("Kaj")
     self.assertEqual(pointsContainer.get_points("Kaj"), 1)
Exemplo n.º 4
0
 def test_create_points_container(self):
     self.assertTrue(PointsContainer() is not None)
Exemplo n.º 5
0
 def test_add_points_by_not_existing_quote(self):
     pointsContainer = PointsContainer()
     pointsContainer.set_players_and_options({"Kaj": "Op1"})
     pointsContainer.add_point_by_quote("Op2")
     self.assertEqual(pointsContainer.get_points("Kaj"), 0)
Exemplo n.º 6
0
 def test_add_points_to_unexisting_player(self):
     pointsContainer = PointsContainer()
     self.assertRaises(Exception, pointsContainer.add_point_to_player,
                       "Kaj", -1)
Exemplo n.º 7
0
 def test_add_negative_points(self):
     pointsContainer = PointsContainer()
     pointsContainer.set_players_and_options({"Kaj": "Op1"})
     self.assertRaises(ValueError, pointsContainer.add_point_to_player,
                       "Kaj", -1)