コード例 #1
0
ファイル: test_views.py プロジェクト: domvcelos/gamma
 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)
コード例 #2
0
ファイル: test_views.py プロジェクト: domvcelos/gamma
 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)
コード例 #3
0
ファイル: test_views.py プロジェクト: domvcelos/gamma
 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)
コード例 #4
0
ファイル: test_views.py プロジェクト: domvcelos/gamma
 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)
コード例 #5
0
ファイル: test_views.py プロジェクト: domvcelos/gamma
 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)
コード例 #6
0
ファイル: test_views.py プロジェクト: domvcelos/gamma
 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)
コード例 #7
0
ファイル: test_views.py プロジェクト: domvcelos/gamma
 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)
コード例 #8
0
 def setUp(self):
     self.game = create_game("Zennynho",
                             package_name="br.com.asus.test.zenny",
                             game_service_id="SERVICE_Id_XPTO",
                             api_key="key")
     self.user = create_user("*****@*****.**", "gpg_id", "gcm_id")
     self.environment_info_data = JsonObjects.environment_info_1()
     create_device_user(game=self.game,
                        gcm_id="testing_gcm_id",
                        email="*****@*****.**")
     self.game2 = create_game("Zenny2",
                              package_name="br.com.asus.test.zenny2",
                              game_service_id="SERVICE_ID_2",
                              api_key="key2")
コード例 #9
0
ファイル: test_views.py プロジェクト: domvcelos/gamma
 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)
コード例 #10
0
ファイル: test_views.py プロジェクト: domvcelos/gamma
 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)
コード例 #11
0
class ParticipantSerializerTestCase(TestCase):
    environment1 = JsonObjects.environment_info_1()
    participant = JsonObjects.participant_without_location(
        location=environment1, player=PLAYER)
    participant_serializer = ParticipationSerializer(data=participant)
    participant_invalid = JsonObjects.participant_without_location()
    participant_serializer_invalid = ParticipationSerializer(
        data=participant_invalid)

    def test_json_participant_is_valid(self):
        is_valid = self.participant_serializer.is_valid(raise_exception=True)
        self.assertTrue(is_valid)

    def test_json_participant_is_not_valid(self):
        is_valid = self.participant_serializer_invalid.is_valid(
            raise_exception=False)
        self.assertFalse(is_valid)