예제 #1
0
    def test_ordered_by_rating(self):
        now = util.now_as_iso_string()
        self.post_player('colin', 1100, now)
        self.post_player('kumanan', 1300, now)
        self.post_player('robert', 1200, now)
        assert Player.query.count() == 3

        names = [player['name'] for player in self.get_players()]
        assert names == ['kumanan', 'robert', 'colin']
예제 #2
0
    def test_response_format(self):
        """Verify the returned Player has all the expected fields."""
        now = util.now_as_iso_string()
        self.post_player('colin', 1100, now)
        assert Player.query.count() == 1

        response = self.client.get('/players/colin')
        assert response.status_code == 200
        player = json.loads(response.data)

        assert player == {
            'name': 'colin',
            'rating': 1100,
            'time_created': now,

            # TODO: add games so that this tests wins/losses
            'num_wins': 0,
            'num_losses': 0,
        }