File: test_guard.py

package info (click to toggle)
trash-cli 0.24.5.26-0.3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,972 kB
  • sloc: python: 9,789; sh: 121; makefile: 11
file content (32 lines) | stat: -rw-r--r-- 1,037 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import unittest

from mock import Mock, call
from trashcli.empty.guard import Guard, UserIntention


class TestGuard(unittest.TestCase):
    def setUp(self):
        self.user = Mock(spec=['do_you_wanna_empty_trash_dirs'])
        self.guard = Guard(self.user)

    def test_user_says_yes(self):
        self.user.do_you_wanna_empty_trash_dirs.return_value = True

        result = self.guard.ask_the_user(True, ['trash_dirs'])

        assert UserIntention(ok_to_empty=True,
                             trash_dirs=['trash_dirs']) == result

    def test_user_says_no(self):
        self.user.do_you_wanna_empty_trash_dirs.return_value = False

        result = self.guard.ask_the_user(True, ['trash_dirs'])

        assert UserIntention(ok_to_empty=False,
                             trash_dirs=[]) == result

    def test_it_just_calls_the_emptier(self):
        result = self.guard.ask_the_user(False, ['trash_dirs'])

        assert UserIntention(ok_to_empty=True,
                             trash_dirs=['trash_dirs']) == result