def test__get_and_send_push__without_valid_push_to_send__zero_pushes_sent( self, mock_pushes, mock_is_valid_to_send): pushes = [Mock(), Mock()] total_push = len(pushes) mock_pushes.return_value = pushes current_time = timezone.now() # Act AsyncAlertsStartedCampaign()._get_push_and_send(current_time) # Assert self.assertEqual(total_push, len(pushes))
def test__verify_in_time__dates_null__is_in_time(self): # Arrange current_time = timezone.now() push = Mock() push.push_begin_date = None push.push_end_date = None # Act in_time = AsyncAlertsStartedCampaign().verify_time(push, current_time) # Assert self.assertTrue(in_time)
def test__verify_in_time_date_is_not_null__is_in_time(self): # Arrange current_time = timezone.now() push = Mock() push.push_begin_date = current_time + timedelta(seconds=-1) push.push_end_date = current_time + timedelta(seconds=1) # Act in_time = AsyncAlertsStartedCampaign().verify_time(push, current_time) # Assert self.assertTrue(in_time)
def test__verify_in_time_end_date_is_null_and_begin_date_bigger_than_current_time__is_not_in_time( self): # Arrange current_time = timezone.now() push = Mock() push.push_begin_date = current_time + timedelta(seconds=1) push.push_end_date = None # Act in_time = AsyncAlertsStartedCampaign().verify_time(push, current_time) # Assert self.assertFalse(in_time)
def test__update_query_in_push__push_without_query__push_updated_with_query( self, mock_get_query): # Arrange push = Mock() push.query = {} # Act AsyncAlertsStartedCampaign()._update_query_in_push(push) # Assert self.assertDictEqual(push.query, {"regions": "BR,AR", "games": "1"})
def test__validate_push_to_send__second_send_and_not_in_time_and_without_data__can_send_equals_false( self, verify_time): # Arrange push = Mock() push.can_send_push = False push.data = {} # Act can_send_push = AsyncAlertsStartedCampaign()._push_valid_to_send( push, timezone.now()) # Assert self.assertFalse(can_send_push)
def test__validate_push_to_send__second_send_and_in_time_and_with_data__can_send_equals_true( self, verify_time): # Arrange push = Mock() push.can_send_push = False push.data = {Constants.MESSAGE: Constants.NAME} # Act can_send_push = AsyncAlertsStartedCampaign()._push_valid_to_send( push, timezone.now()) # Assert self.assertFalse(can_send_push)
def test__get_and_send_push__valid_push_to_send_and_status_paused__zero_pushes_sent( self, mock_pushes, mock_is_valid_to_send): # Arrange campaign_push = Mock() campaign_push.rule = Mock() campaign_push.rule.campaign.status = Constants.STATUS_PAUSED pushes = [campaign_push, Mock()] total_push = len(pushes) mock_pushes.return_value = pushes current_time = timezone.now() # Act AsyncAlertsStartedCampaign()._get_push_and_send(current_time) # Assert self.assertEqual(total_push, len(pushes))
def test__get_query_in_campaign_push__push_rule__query_to_push(self): # Arrange game = Mock() game.id = 1 campaign = Mock() campaign.countries_codes = ["BR", "AR"] push = Mock() push.rule.campaign = campaign push.rule.game = game # Act query = AsyncAlertsStartedCampaign().get_query_to_campaign_push(push) # Assert self.assertDictEqual(query, {"regions": "BR,AR", "games": "1"})
""" WSGI config for gmm project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/ """ import os from django.core.wsgi import get_wsgi_application os.environ.setdefault("DJANGO_SETTINGS_MODULE", "gmm.settings") application = get_wsgi_application() from gmm.events_asynchronous import AsyncAlertsStartedCampaign #THIS LINE SHOULD STAY HERE. AsyncAlertsStartedCampaign().alerts_started_campaign()