From e42eb419487c4de02ae1b94417d05aa24abbf6f1 Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Wed, 14 Sep 2016 16:03:09 -0700 Subject: [PATCH] Delete temp objects to avoid constraint error Django 1.10 with Postgres 9.? was throwing an error because the samples_htsuser id that was assigned to an affiliation didn't exist in the database. The simplest solution I found was to delete the objects from the ORM, I don't think they were ever actually created in the db so I'm not sure how the constraint check was happening. --- experiments/test_experiments.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/experiments/test_experiments.py b/experiments/test_experiments.py index b862d7b..584a812 100644 --- a/experiments/test_experiments.py +++ b/experiments/test_experiments.py @@ -91,6 +91,9 @@ class ExperimentsTestCases(TestCase): def tearDown(self): shutil.rmtree(self.tempdir) + self.user_odd.delete() + self.user_even.delete() + self.admin.delete() def test_flowcell_information(self): """ @@ -444,9 +447,9 @@ class TestEmailNotify(TestCase): self.admin = HTSUserFactory.create(username='admintest', is_staff=True) self.admin.set_password(self.password) self.admin.save() - self.super = HTSUserFactory.create(username='supertest', is_staff=True, is_superuser=True) - self.super.set_password(self.password) - self.super.save() + self.superuser = HTSUserFactory.create(username='supertest', is_staff=True, is_superuser=True) + self.superuser.set_password(self.password) + self.superuser.save() self.library = LibraryFactory.create() self.affiliation = AffiliationFactory() @@ -457,6 +460,14 @@ class TestEmailNotify(TestCase): self.url = '/experiments/started/{}/'.format(self.fc.id) + def tearDown(self): + # with django 1.10 running against postgresql I had to delete these + # test objects or else I get a constraint error + self.affiliation.delete() + self.user.delete() + self.admin.delete() + self.superuser.delete() + def test_started_email_not_logged_in(self): response = self.client.get(self.url) self.assertEqual(response.status_code, 302) -- 2.30.2