from mock import patch

from sms.tests.test_sms import GarfieldTwilioTestCase
from sms.tests.test_sms import GarfieldTwilioTestClient


class GarfieldTestSimSmsCaseNewJohn(GarfieldTwilioTestCase):
    @patch('sms.tasks.save_sms_message.apply_async')
    def test_sim_receive_sms(self, mock_save_sms_message):
        response = self.client.sms("Test.",
                                   path="/sims/sms/receive/")

        self.assert_twiml(response)
        self.assertTrue(mock_save_sms_message.called)

    @patch('sms.tasks.save_sms_message.apply_async')
    def test_sim_send_sms(self, mock_save_sms_message):
        response = self.client.sms("Test.",
                                   path="/sims/sms/send/")

        self.assert_twiml(response)
        self.assertTrue(mock_save_sms_message.called)


class GarfieldTestSimVoiceCase(GarfieldTwilioTestCase):
    def test_sims_receive_call(self):
        response = self.client.call("Test.",
                                    path="/sims/voice/receive/")

        self.assert_twiml(response)

    def test_sims_send_call(self):
        response = self.client.call("Test.",
                                    path="/sims/voice/send/")

        self.assert_twiml(response)

from django.test import override_settings

from mock import patch

from sms.tests.test_sms import GarfieldTwilioTestCase
from sms.tests.test_sms import GarfieldTwilioTestClient


@override_settings(TWILIO_PHONE_NUMBER="+15558675309")
class GarfieldTestSimSmsCaseNewJohn(GarfieldTwilioTestCase):
    @patch('sms.tasks.save_sms_message.apply_async')
    def test_sim_receive_sms(self, mock_save_sms_message):
        response = self.client.sms("Test.",
                                   path="/sims/sms/receive/")

        self.assert_twiml(response)
        self.assertTrue(mock_save_sms_message.called)

    @patch('sms.tasks.save_sms_message.apply_async')
    def test_sim_send_sms(self, mock_save_sms_message):
        response = self.client.sms("Test.",
                                   path="/sims/sms/send/")

        self.assert_twiml(response)
        self.assertTrue(mock_save_sms_message.called)


@override_settings(TWILIO_PHONE_NUMBER="+15558675309")
class GarfieldTestSimVoiceCase(GarfieldTwilioTestCase):
    def test_sims_receive_call(self):
        response = self.client.call("Test.",
                                    path="/sims/voice/receive/")

        self.assert_twiml(response)

    def test_sims_send_call(self):
        response = self.client.call("Test.",
                                    path="/sims/voice/send/")

        self.assert_twiml(response)

Add override settings for CI without local settings.
Add override settings for CI without local settings.

+ from django.test import override_settings
+ 
  from mock import patch
  
  from sms.tests.test_sms import GarfieldTwilioTestCase
  from sms.tests.test_sms import GarfieldTwilioTestClient
  
  
+ @override_settings(TWILIO_PHONE_NUMBER="+15558675309")
  class GarfieldTestSimSmsCaseNewJohn(GarfieldTwilioTestCase):
      @patch('sms.tasks.save_sms_message.apply_async')
      def test_sim_receive_sms(self, mock_save_sms_message):
          response = self.client.sms("Test.",
                                     path="/sims/sms/receive/")
  
          self.assert_twiml(response)
          self.assertTrue(mock_save_sms_message.called)
  
      @patch('sms.tasks.save_sms_message.apply_async')
      def test_sim_send_sms(self, mock_save_sms_message):
          response = self.client.sms("Test.",
                                     path="/sims/sms/send/")
  
          self.assert_twiml(response)
          self.assertTrue(mock_save_sms_message.called)
  
  
+ @override_settings(TWILIO_PHONE_NUMBER="+15558675309")
  class GarfieldTestSimVoiceCase(GarfieldTwilioTestCase):
      def test_sims_receive_call(self):
          response = self.client.call("Test.",
                                      path="/sims/voice/receive/")
  
          self.assert_twiml(response)
  
      def test_sims_send_call(self):
          response = self.client.call("Test.",
                                      path="/sims/voice/send/")
  
          self.assert_twiml(response)
  
Add override settings for CI without local settings.
## Code Before:
from mock import patch

from sms.tests.test_sms import GarfieldTwilioTestCase
from sms.tests.test_sms import GarfieldTwilioTestClient


class GarfieldTestSimSmsCaseNewJohn(GarfieldTwilioTestCase):
    @patch('sms.tasks.save_sms_message.apply_async')
    def test_sim_receive_sms(self, mock_save_sms_message):
        response = self.client.sms("Test.",
                                   path="/sims/sms/receive/")

        self.assert_twiml(response)
        self.assertTrue(mock_save_sms_message.called)

    @patch('sms.tasks.save_sms_message.apply_async')
    def test_sim_send_sms(self, mock_save_sms_message):
        response = self.client.sms("Test.",
                                   path="/sims/sms/send/")

        self.assert_twiml(response)
        self.assertTrue(mock_save_sms_message.called)


class GarfieldTestSimVoiceCase(GarfieldTwilioTestCase):
    def test_sims_receive_call(self):
        response = self.client.call("Test.",
                                    path="/sims/voice/receive/")

        self.assert_twiml(response)

    def test_sims_send_call(self):
        response = self.client.call("Test.",
                                    path="/sims/voice/send/")

        self.assert_twiml(response)

## Instruction:
Add override settings for CI without local settings.
## Code After:
from django.test import override_settings

from mock import patch

from sms.tests.test_sms import GarfieldTwilioTestCase
from sms.tests.test_sms import GarfieldTwilioTestClient


@override_settings(TWILIO_PHONE_NUMBER="+15558675309")
class GarfieldTestSimSmsCaseNewJohn(GarfieldTwilioTestCase):
    @patch('sms.tasks.save_sms_message.apply_async')
    def test_sim_receive_sms(self, mock_save_sms_message):
        response = self.client.sms("Test.",
                                   path="/sims/sms/receive/")

        self.assert_twiml(response)
        self.assertTrue(mock_save_sms_message.called)

    @patch('sms.tasks.save_sms_message.apply_async')
    def test_sim_send_sms(self, mock_save_sms_message):
        response = self.client.sms("Test.",
                                   path="/sims/sms/send/")

        self.assert_twiml(response)
        self.assertTrue(mock_save_sms_message.called)


@override_settings(TWILIO_PHONE_NUMBER="+15558675309")
class GarfieldTestSimVoiceCase(GarfieldTwilioTestCase):
    def test_sims_receive_call(self):
        response = self.client.call("Test.",
                                    path="/sims/voice/receive/")

        self.assert_twiml(response)

    def test_sims_send_call(self):
        response = self.client.call("Test.",
                                    path="/sims/voice/send/")

        self.assert_twiml(response)
