class TestUpdateClosedTask(TestCase): def setUp(self): settings.CELERY_ALWAYS_EAGER = True self.email = "*****@*****.**" self.pleb = create_user_util_test(self.email) self.user = User.objects.get(email=self.email) self.flag = Flag().save() self.question = Question(title=str(uuid1())).save() self.question.flags.connect(self.flag) self.vote_rel = self.question.council_votes.connect(self.pleb) self.vote_rel.active = True self.vote_rel.vote_type = True self.vote_rel.save() def tearDown(self): settings.CELERY_ALWAYS_EAGER = False def test_updated_closed(self): task_data = {'object_uuid': self.question.object_uuid} res = update_closed_task.apply_async(kwargs=task_data) while not res.ready(): time.sleep(1) self.assertFalse(isinstance(res.result, Exception)) self.question.refresh() self.assertTrue(self.question.is_closed)
class TestUpdateClosed(TestCase): def setUp(self): self.unit_under_test_name = 'sbcontent' self.email = "*****@*****.**" create_user_util_test(self.email) self.pleb = Pleb.nodes.get(email=self.email) self.user = User.objects.get(email=self.email) self.url = "http://testserver" self.flag = Flag().save() self.question = Question(owner_username=self.pleb.username, title=str(uuid1())).save() self.question.owned_by.connect(self.pleb) self.question.flags.connect(self.flag) self.vote_rel = self.question.council_votes.connect(self.pleb) self.vote_rel.active = True self.vote_rel.vote_type = True self.vote_rel.save() def test_update_closed(self): res = update_closed(self.question.object_uuid) self.assertTrue(res) self.question.refresh() self.assertTrue(self.question.is_closed) def test_update_closed_to_open(self): self.vote_rel.vote_type = False self.vote_rel.save() res = update_closed(self.question.object_uuid) self.assertTrue(res) self.question.refresh() self.assertFalse(self.question.is_closed) def test_update_closed_inactive(self): self.vote_rel.active = False self.vote_rel.save() res = update_closed(self.question.object_uuid) self.assertTrue(res) self.question.refresh() self.assertFalse(self.question.is_closed)