import unittest

from celery import Celery
from django.conf import settings
from django.db import connection


class SmokeTests(unittest.TestCase):

    def setUp(self):
        pass

    def test_can_access_db(self):
        "access the database"
        cursor = connection.cursor()
        cursor.execute('SELECT 1')
        row = cursor.fetchone()
        self.assertEqual(1, row[0])

    def test_can_access_celery(self):
        "connect to SQS"
        if not getattr(settings, 'CELERY_ALWAYS_EAGER', False):
            conn = Celery('cla_backend').connection()
            conn.config_from_object('django.conf:settings')
            conn.connect()
            conn.release()

import unittest

from celery import Celery
from django.conf import settings
from django.db import connection


class SmokeTests(unittest.TestCase):

    def setUp(self):
        pass

    def test_can_access_db(self):
        "access the database"
        cursor = connection.cursor()
        cursor.execute('SELECT 1')
        row = cursor.fetchone()
        self.assertEqual(1, row[0])

    def test_can_access_celery(self):
        "connect to SQS"
        if not getattr(settings, 'CELERY_ALWAYS_EAGER', False):
            app = Celery('cla_backend')
            app.config_from_object('django.conf:settings')
            app.connection().connect()
            conn.connect()
            conn.release()

Configure Celery correctly in smoketest
Configure Celery correctly in smoketest

  import unittest
  
  from celery import Celery
  from django.conf import settings
  from django.db import connection
  
  
  class SmokeTests(unittest.TestCase):
  
      def setUp(self):
          pass
  
      def test_can_access_db(self):
          "access the database"
          cursor = connection.cursor()
          cursor.execute('SELECT 1')
          row = cursor.fetchone()
          self.assertEqual(1, row[0])
  
      def test_can_access_celery(self):
          "connect to SQS"
          if not getattr(settings, 'CELERY_ALWAYS_EAGER', False):
-             conn = Celery('cla_backend').connection()
+             app = Celery('cla_backend')
-             conn.config_from_object('django.conf:settings')
+             app.config_from_object('django.conf:settings')
+             app.connection().connect()
              conn.connect()
              conn.release()
  
Configure Celery correctly in smoketest
## Code Before:
import unittest

from celery import Celery
from django.conf import settings
from django.db import connection


class SmokeTests(unittest.TestCase):

    def setUp(self):
        pass

    def test_can_access_db(self):
        "access the database"
        cursor = connection.cursor()
        cursor.execute('SELECT 1')
        row = cursor.fetchone()
        self.assertEqual(1, row[0])

    def test_can_access_celery(self):
        "connect to SQS"
        if not getattr(settings, 'CELERY_ALWAYS_EAGER', False):
            conn = Celery('cla_backend').connection()
            conn.config_from_object('django.conf:settings')
            conn.connect()
            conn.release()

## Instruction:
Configure Celery correctly in smoketest
## Code After:
import unittest

from celery import Celery
from django.conf import settings
from django.db import connection


class SmokeTests(unittest.TestCase):

    def setUp(self):
        pass

    def test_can_access_db(self):
        "access the database"
        cursor = connection.cursor()
        cursor.execute('SELECT 1')
        row = cursor.fetchone()
        self.assertEqual(1, row[0])

    def test_can_access_celery(self):
        "connect to SQS"
        if not getattr(settings, 'CELERY_ALWAYS_EAGER', False):
            app = Celery('cla_backend')
            app.config_from_object('django.conf:settings')
            app.connection().connect()
            conn.connect()
            conn.release()
