def test_twilio_domain_level_backend(self, mock_log_smsbillables_error): add_twilio_gateway_fee(apps) bootstrap_usage_fees(apps) twilio_backend = SQLTwilioBackend.objects.create( name='TWILIO', is_global=False, hq_api_id=SQLTwilioBackend.get_api_id(), couch_id='domain_backend', ) twilio_backend.set_extra_fields( account_sid='sid', auth_token='token', ) twilio_backend.save() messages = [ message for phone_number in [generator.arbitrary_phone_number() for _ in range(10)] for message in generator.arbitrary_messages_by_backend_and_direction( {twilio_backend.hq_api_id: twilio_backend.couch_id}, phone_number=phone_number) ] for msg_log in messages: FakeTwilioMessageFactory.add_price_for_message( msg_log.backend_message_id, generator.arbitrary_fee()) for msg_log in messages: multipart_count = randint(1, 10) # Should be ignored billable = SmsBillable.create(msg_log, multipart_count=multipart_count) self.assertIsNotNone(billable) self.assertIsNone(billable.gateway_fee) self.assertEqual(billable.gateway_charge, 0) self.assertEqual(mock_log_smsbillables_error.call_count, 0)
def test_twilio_domain_level_backend(self, mock_log_smsbillables_error): add_twilio_gateway_fee(apps) bootstrap_usage_fees(apps) twilio_backend = SQLTwilioBackend.objects.create( name='TWILIO', is_global=False, hq_api_id=SQLTwilioBackend.get_api_id(), couch_id='domain_backend', ) twilio_backend.set_extra_fields( account_sid='sid', auth_token='token', ) twilio_backend.save() messages = [ message for phone_number in [generator.arbitrary_phone_number() for _ in range(10)] for message in generator.arbitrary_messages_by_backend_and_direction( {twilio_backend.hq_api_id: twilio_backend.couch_id}, phone_number=phone_number ) ] for msg_log in messages: FakeTwilioMessageFactory.add_price_for_message(msg_log.backend_message_id, generator.arbitrary_fee()) for msg_log in messages: multipart_count = randint(1, 10) # Should be ignored billable = SmsBillable.create(msg_log, multipart_count=multipart_count) self.assertIsNotNone(billable) self.assertIsNone(billable.gateway_fee) self.assertEqual(billable.gateway_charge, 0) self.assertEqual(mock_log_smsbillables_error.call_count, 0)
def test_non_global_backends_with_direct_provider_fees( self, mock_log_smsbillables_error): bootstrap_twilio_gateway(apps) bootstrap_infobip_gateway(apps) bootstrap_usage_fees(apps) backends = generator.arbitrary_non_global_with_direct_fees_backends() for backend in backends: messages = [ message for phone_number in [generator.arbitrary_phone_number() for _ in range(10)] for message in generator.arbitrary_messages_by_backend_and_direction( {backend.hq_api_id: backend.couch_id}, phone_number=phone_number) ] for msg_log in messages: FakeMessageFactory.add_price_for_message( msg_log.backend_message_id, generator.arbitrary_fee()) for msg_log in messages: multipart_count = randint(1, 10) # Should be ignored billable = SmsBillable.create(msg_log, multipart_count=multipart_count) self.assertIsNotNone(billable) self.assertIsNone(billable.gateway_fee) self.assertEqual(billable.gateway_charge, 0) self.assertEqual(mock_log_smsbillables_error.call_count, 0)
def bootstrap_sms(apps, schema_editor): bootstrap_grapevine_gateway(apps) bootstrap_mach_gateway(apps) bootstrap_tropo_gateway(apps) bootstrap_unicel_gateway(apps) bootstrap_usage_fees(apps) bootstrap_moz_gateway(apps) bootstrap_test_gateway(apps) bootstrap_telerivet_gateway(apps) bootstrap_yo_gateway(apps) add_moz_zero_charge(apps) bootstrap_grapevine_gateway_update(apps)
def bootstrap_sms(apps, schema_editor): bootstrap_grapevine_gateway(apps) bootstrap_mach_gateway(apps) bootstrap_tropo_gateway(apps) bootstrap_twilio_gateway( apps, 'corehq/apps/smsbillables/management/commands/pricing_data/twilio-rates-2015_10_06.csv' ) bootstrap_unicel_gateway(apps) bootstrap_usage_fees(apps) bootstrap_moz_gateway(apps) bootstrap_test_gateway(apps) bootstrap_telerivet_gateway(apps) bootstrap_twilio_gateway_incoming(apps) bootstrap_yo_gateway(apps) add_moz_zero_charge(apps) bootstrap_grapevine_gateway_update(apps)