def test_take_twice_forced(self): u1 = UserFactory() u2 = UserFactory() q = QuestionFactory() q.take(u1) q.take(u2, force=True) eq_(q.taken_by, u2)
def test_is_taken(self): q = QuestionFactory() u = UserFactory() q.take(u) url = reverse('question-detail', args=[q.id]) res = self.client.get(url) eq_(res.status_code, 200) eq_(res.data['taken_by']['username'], u.username)
def test_filter_taken_by_username(self): q1 = QuestionFactory() q2 = QuestionFactory() q2.take(q1.creator) url = reverse('question-list') + '?taken_by=' + q1.creator.username res = self.client.get(url) eq_(res.status_code, 200) eq_(res.data['count'], 1) eq_(res.data['results'][0]['id'], q2.id)
def test_filter_is_taken_false(self): q1 = QuestionFactory() q2 = QuestionFactory() q2.take(q1.creator) url = reverse('question-list') + '?is_taken=0' res = self.client.get(url) eq_(res.status_code, 200) eq_(res.data['count'], 1) eq_(res.data['results'][0]['id'], q1.id)
def test_taken_until_is_set(self): u = UserFactory() q = QuestionFactory() q.take(u) assert q.taken_until > datetime.now()
def test_take_twice_same_user_refreshes_time(self): u = UserFactory() first_taken_until = datetime.now() - timedelta(minutes=5) q = QuestionFactory(taken_by=u, taken_until=first_taken_until) q.take(u) ok_(q.taken_until > first_taken_until)
def test_take_twice_fails(self): u1 = UserFactory() u2 = UserFactory() q = QuestionFactory() q.take(u1) q.take(u2)
def test_take_creator(self): q = QuestionFactory() q.take(q.creator)
def test_take(self): u = UserFactory() q = QuestionFactory() q.take(u) eq_(q.taken_by, u) ok_(q.taken_until is not None)