mercredi 29 juillet 2020

ProgrammingError during TestCase

I am trying to create my first functional TestCase and having an issue with a ProgrammingError occurring. I will first start by showing my TestCase.

Note: I am using TenantTestCase because I am using Django-Tenant-Schemas to separate clients to separate schemas/sub-domains. I am not sure what self.c = TenantClient(self.tenant) does.

class FunctionalTestCase(TenantTestCase):
    def setUp(self):
        self.browser = webdriver.Chrome()
        self.c = TenantClient(self.tenant)

    def test_company_reg_btn_works(self):
        self.browser.get('http://localhost:8000')
        time.sleep(3)
        reg_btn = self.browser.find_element_by_id('register-link')
        reg_btn.click()
        self.c.get('/company-reg/', follow=True)

    def tearDown(self):
        self.browser.quit()

After running this I get the traceback:

  File "/home/david/PycharmProjects/clearpath_project/venv/lib/python3.8/site-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/home/david/PycharmProjects/clearpath_project/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "memos_memo_company" does not exist
LINE 1: ..."memo_id", "memos_memo_company"."company_id" FROM "memos_mem...

The usual way to make migrations and then migrate would be these commands:

python manage.py makemigrations
python manage.py migrate_schemas --shared
python manage.py migrate_schemas --tenant

And then I would create a tenant by:

python manage.py create_tenant

I am guessing this error is occurring as if the migration has not been run, but I am not sure. Can someone help explain what may cause this?

Aucun commentaire:

Enregistrer un commentaire