-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2194 from SpaceFox/fix_2160
Fixes #2160: Un MP peut ne pas avoir de participants
- Loading branch information
Showing
2 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# coding: utf-8 | ||
|
||
from django.test import TestCase | ||
|
||
from zds.member.factories import ProfileFactory | ||
from zds.mp.factories import PrivateTopicFactory, PrivatePostFactory | ||
from zds.utils.templatetags.interventions import interventions_privatetopics | ||
|
||
|
||
class InterventionsTest(TestCase): | ||
|
||
def setUp(self): | ||
self.author = ProfileFactory() | ||
self.user = ProfileFactory() | ||
self.topic = PrivateTopicFactory(author=self.author.user) | ||
self.topic.participants.add(self.user.user) | ||
self.post = PrivatePostFactory( | ||
privatetopic=self.topic, | ||
author=self.author.user, | ||
position_in_topic=1) | ||
|
||
def test_interventions_privatetopics(self): | ||
result = interventions_privatetopics(self.author) | ||
self.assertEqual(result['total'], 1) | ||
|
||
result = interventions_privatetopics(self.user) | ||
self.assertEqual(result['total'], 1) | ||
|
||
def test_interventions_privatetopics_author_leave(self): | ||
|
||
# profile1 (author) leave topic | ||
move = self.topic.participants.first() | ||
self.topic.author = move | ||
self.topic.participants.remove(move) | ||
self.topic.save() | ||
|
||
result = interventions_privatetopics(self.user) | ||
self.assertEqual(result['total'], 1) |