Total Complexity | 4 |
Total Lines | 24 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | # -*- coding: utf-8 -*- |
||
2 | # pylint: disable=invalid-name, no-member |
||
3 | |||
4 | from tcms.tests import BasePlanCase |
||
5 | |||
6 | |||
7 | class RemoveUserWhenThereIsHistory(BasePlanCase): |
||
8 | def setUp(self): |
||
9 | self.case.summary = 'editted to generate history' |
||
10 | self.case.save() |
||
11 | # map history to a user which we try to delete later |
||
12 | for history_record in self.case.history.all(): |
||
13 | history_record.history_user = self.tester |
||
14 | history_record.save() |
||
15 | |||
16 | def test_remove_user(self): |
||
17 | self.tester.delete() |
||
18 | # 2 edits + 1 cascade delete |
||
19 | self.assertEqual(3, self.case.history.count()) |
||
20 | |||
21 | # when users are removed this is supposed to be set to None |
||
22 | for history_record in self.case.history.all(): |
||
23 | self.assertIsNone(history_record.history_user) |
||
24 |