def test__get__no_location__status_400(self, mock_404): # Arrange request = self.factory.get( self.url, HTTP_X_TOKEN=EnvironmentConfiguration.get_token(False)) # Act response = self.view(request) # Assert self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
def test__get__banners_found__status_200(self, mock_404, mock_filter): # Arrange request = self.factory.get( self.url, HTTP_X_ENV=JsonObjects.environment_info_1(), HTTP_X_TOKEN=EnvironmentConfiguration.get_token(False)) # Act response = self.view(request) # Assert self.assertEqual(response.status_code, status.HTTP_200_OK)
def test__get__game_does_not_exist__status_200(self, mock_404): # Arrange request = self.factory.get( self.url, HTTP_X_ENV=JsonObjects.environment_info_1(), HTTP_X_TOKEN=EnvironmentConfiguration.get_token(False)) # Act response = self.view(request) # Assert self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
def test__get__invalid_location__status_400(self): # Arrange request = self.factory.get( self.url, HTTP_X_ENV={'invalid_field': 'invalid_value'}, HTTP_X_TOKEN=EnvironmentConfiguration.get_token(False)) # Act response = self.view(request, 1, 1, '*****@*****.**') # Assert self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
def test__get__data_exists_exists__status_200(self): # Arrange request = self.factory.get( self.url, HTTP_X_ENV=JsonObjects.environment_info_1(), HTTP_X_TOKEN=EnvironmentConfiguration.get_token(False)) # Act response = self.view(request, 1, 1, '*****@*****.**') # Assert self.assertEqual(response.status_code, status.HTTP_200_OK)
def test__post__valid_data__status_201(self, mock_serializer): # Arrange request = self.factory.post( self.url, {}, HTTP_X_ENV=JsonObjects.environment_info_1(), HTTP_X_TOKEN=EnvironmentConfiguration.get_token(False)) # Act response = self.view(request, 1) # Assert self.assertEqual(response.status_code, status.HTTP_201_CREATED)
def test__get__campaign_does_not_exist__status_200(self): # Arrange self.mock_participation_manager.side_effect = Campaign.DoesNotExist() request = self.factory.get( self.url, HTTP_X_ENV=JsonObjects.environment_info_1(), HTTP_X_TOKEN=EnvironmentConfiguration.get_token(False)) # Act response = self.view(request, 1, 1, '*****@*****.**') # Assert self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
def test__post__game_does_not_exist__status_201(self, mock_serializer): # Arrange self.mock_game_manager.side_effect = Game.DoesNotExist request = self.factory.post( self.url, {}, HTTP_X_ENV=JsonObjects.environment_info_1(), HTTP_X_TOKEN=EnvironmentConfiguration.get_token(False)) # Act response = self.view(request, 1) # Assert self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
def test__post__valid_data__status_201(self, mock_serializer, mock_device_user): # Arrange mock_instance = Mock() mock_serializer.return_value = mock_instance request = self.factory.post( self.url, {'player': {'email': '*****@*****.**', 'gpg_id': '1', 'gcm_id': '1'}}, HTTP_X_ENV=JsonObjects.environment_info_1(), HTTP_X_TOKEN=EnvironmentConfiguration.get_token(False)) # Act response = self.view(request, 1, 1) # Assert self.assertEqual(response.status_code, status.HTTP_201_CREATED)
def test__post__existing_player__status_201(self, mock_serializer): # Arrange mock_instance = Mock() mock_serializer.return_value = mock_instance mock_instance.create_or_update.return_value = False request = self.factory.post( self.url, {}, HTTP_X_ENV=JsonObjects.environment_info_1(), HTTP_X_TOKEN=EnvironmentConfiguration.get_token(False)) # Act response = self.view(request, 1) # Assert self.assertEqual(response.status_code, status.HTTP_200_OK)
def test__post__invalid_data__status_400(self, mock_serializer): # Arrange mock_instance = Mock() mock_serializer.return_value = mock_instance mock_instance.is_valid.side_effect = ValidationError({}) request = self.factory.post( self.url, {}, HTTP_X_ENV=JsonObjects.environment_info_1(), HTTP_X_TOKEN=EnvironmentConfiguration.get_token(False)) # Act response = self.view(request, 1) # Assert self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)