Exemplo n.º 1
0
    def setUp(self):
        """
        Create a new account and create sample category
        """
        url = "/register"
        data = {
            "username": "******",
            "password": "******",
            "email": "*****@*****.**",
            "first_name": "Steve",
            "last_name": "Brownlee",
            "bio": "Love those gamez!!"
        }
        # Initiate request and capture response
        response = self.client.post(url, data, format='json')

        # Parse the JSON in the response body
        json_response = json.loads(response.content)

        # Store the auth token
        self.token = json_response["token"]

        # Assert that a user was created
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)

        # SEED DATABASE WITH ONE GAME TYPE
        # This is needed because the API does not expose a /gametypes
        # endpoint for creating game types
        gametype = GameType()
        gametype.label = "Board game"
        gametype.save()
Exemplo n.º 2
0
    def setUp(self):
        #create new account and sample category
        url = '/register'
        data = {
            'username': '******',
            'password': '******',
            'email': '*****@*****.**',
            'address': '100 Infinity Way',
            'phone_number': '555-1212',
            'first_name': 'Steve',
            'last_name': 'Brownlee',
            'bio': 'Love those gamez!!'
        }
        #initiate request and grab the response
        response = self.client.post(url, data, format='json')
        #parse the JSON in the resonse body
        fuckin_json_response = json.loads(response.content)
        #store teh AUTH Token
        self.token = fuckin_json_response['token']
        #assert that a user was created
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)

        #seed the DB wit one game type so it don't break and there's no URL endpoint for creating GTs
        gametype = GameType()
        gametype.label = 'Classic Type'
        gametype.save()
        #now make a dummy game and save it
        game = Game()
        game.game_type_id = 1
        game.title = 'Chess'
        game.description = 'GOAT Board Game'
        game.number_of_players = 2
        game.gamer_id = 1
        game.save()
Exemplo n.º 3
0
    def setUp(self):
        url = '/register'
        data = {
            "username": "******",
            "password": "******",
            "email": "*****@*****.**",
            "address": "100 Infinity Way",
            "phone_number": "555-1212",
            "first_name": "Steve",
            "last_name": "Brownlee",
            "bio": "Love those gamez!!"
        }

        response = self.client.post(url, data, format='json')
        json_response = json.loads(response.content)
        self.token = json_response['token']
        self.client.credentials(HTTP_AUTHORIZATION=f'Token {self.token}')
        # response.status_code == status.HTTP_201_CREATED
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)

        game_type = GameType()
        game_type.label = "Board Game"
        game_type.save()

        self.game = Game()
        self.game.game_type_id = 1
        self.game.skill_level = 5
        self.game.title = "Monopoly"
        self.game.maker = "Milton Bradley"
        self.game.number_of_players = 4
        self.game.gamer_id = 1

        self.game.save()
Exemplo n.º 4
0
    def setUp(self):

        url = "/register"
        data = {
            "username": "******",
            "password": "******",
            "email": "*****@*****.**",
            "first_name": "Steve",
            "last_name": "Brownlee",
            "bio": "Love those gamez!!"
        }

        response = self.client.post(url, data, format='json')

        json_response = json.loads(response.content)

        self.token = json_response["token"]

        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        
        gametype = GameType()
        gametype.label = "Board game"
        
        gametype.save()
        
        # url = "/games"
        # data = {
        #     "gamer": 1,
        #     "game_type": 1,
        #     "title": "Balderdash",
        #     "number_of_players": 2,
        #     "description": "fun"
        # }

        # response = self.client.post(url, data, format='json')

        # json_response = json.loads(response.content)

        # self.token = json_response["token"]
        # self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        
        game = Game()
        game.game_type = gametype
        game.title = "Balderdash"
        game.number_of_players = 4
        game.gamer_id = 1
        game.save()
Exemplo n.º 5
0
    def setUp(self):
        """
        Create a new account and create sample category
        """
        url = "/register"
        data = {
            "username": "******",
            "password": "******",
            "email": "*****@*****.**",
            "address": "100 Infinity Way",
            "phone_number": "555-1212",
            "first_name": "Steve",
            "last_name": "Brownlee",
            "bio": "Love those eventz!!"
        }
        # Initiate request and capture response
        response = self.client.post(url, data, format='json')

        # Parse the JSON in the response body
        json_response = json.loads(response.content)

        # Store the auth token
        self.token = json_response["token"]

        # Assert that a user was created
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)

        # SEED DATABASE WITH ONE GAME TYPE
        # This is needed because the API does not expose a /gametypes
        # endpoint for creating game types
        gametype = GameType()
        gametype.label = "Board game"
        gametype.save()

        # SEED DATABASE WITH ONE game
        # This is needed because the API does not expose a /game
        # endpoint for creating game
        game = Game()
        game.gamer_id = 1
        game.gametype_id = gametype.id
        game.skill_level = 5
        game.number_of_players = 3
        game.maker = "Wizards of the Coast"
        game.title = "Dungeons & Dragons"
        game.save()
Exemplo n.º 6
0
    def setUp(self):
        """
        Create a new account and create sample category
        """
        url = "/register"
        data = {
            "username": "******",
            "password": "******",
            "email": "*****@*****.**",
            "address": "100 Infinity Way",
            "phone_number": "555-1212",
            "first_name": "Steve",
            "last_name": "Brownlee",
            "bio": "Love those gamez!!"
        }
        # Initiate request and capture response
        response = self.client.post(url, data, format='json')

        # Parse the JSON in the response body
        json_response = json.loads(response.content)

        # Store the auth token
        self.token = json_response["token"]

        self.client.credentials(HTTP_AUTHORIZATION=f'Token {self.token}')
        # response.status_code == status.HTTP_201_CREATED

        # Assert that a user was created
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)

        # SEED DATABASE WITH ONE GAME TYPE
        # This is needed because the API does not expose a /gametypes
        # endpoint for creating game types
        gametype = GameType()
        gametype.label = "Board game"
        gametype.save()

        self.game = Game()
        self.game.gametype_id = 1
        self.game.title = "Monopoly"
        self.game.instructions = ""
        self.game.max_players = 6
        self.game.gamer = 1

        self.game.save()
Exemplo n.º 7
0
    def setUp(self):
        """
        Create a new account and create sample category
        """
        url = "/register"
        data = {
            "username": "******",
            "password": "******",
            "email": "*****@*****.**",
            "address": "100 Infinity Way",
            "phone_number": "555-1212",
            "first_name": "Jon",
            "last_name": "Shearon",
            "bio": "Love those gamez!!"
        }
        # Initiate request and capture response
        response = self.client.post(url, data, format='json')

        # Parse the JSON in the response body
        json_response = json.loads(response.content)

        # Store the auth token
        self.token = json_response["token"]

        # Assert that a user was created
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)

        # SEED DATABASE WITH ONE GAME TYPE
        # This is needed because the API does not expose a /gametypes
        # endpoint for creating game types
        gametype = GameType()
        gametype.label = "Board game"
        gametype.save()

        game = Game()
        game.gametype = GameType.objects.get(pk=1)
        game.skill_level = 5
        game.title = "Clue"
        game.maker = "Milton Bradley"
        game.number_of_players = 6
        game.gamer = Gamer.objects.get(pk=1)
        game.save()
Exemplo n.º 8
0
    def setUp(self):
        """
        Create a new account and create sample category
        """
        url = "/register"
        data = {
            "username": "******",
            "password": "******",
            "email": "*****@*****.**",
            "address": "100 Infinity Way",
            "phone_number": "555-1212",
            "first_name": "Steve",
            "last_name": "Brownlee",
            "bio": "Love those gamez!!"
        }

        # Initiate request and capture response
        response = self.client.post(url, data, format='json')

        # Parse the JSON in the response body
        json_response = json.loads(response.content)

        # Store the auth token
        self.token = json_response["token"]

        # Assert that a user was created
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)

        gametype = GameType()
        gametype.label = "Board game"
        gametype.save()

        game = Game()
        game.title = "title"
        game.number_of_players = 4
        game.description = "This gmae is fun"
        game.gamer_id = 1
        game_type = 1
        game.game_type_id = game_type
        game.save()
Exemplo n.º 9
0
    def setUp(self):
        """
        Create a new account and set up a game
        """
        url = "/register"
        data = {
            "username": "******",
            "password": "******",
            "email": "*****@*****.**",
            "first_name": "Steve",
            "last_name": "Brownlee",
            "bio": "Love those eventz!!"
        }
        # Initiate request and capture response
        response = self.client.post(url, data, format='json')

        # Parse the JSON in the response body
        json_response = json.loads(response.content)

        # Store the auth token
        self.token = json_response["token"]

        # Assert that a user was created
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)

        # Seed database with one game type
        gametype = GameType()
        gametype.label = "Board game"
        gametype.save()

        # Seed database with one game
        game = Game()
        game.title = "Checkers"
        game.gametype_id = 1
        game.number_of_players = 2
        game.gamer_id = 1
        game.description = "Great game"
        game.save()