File: test_update.py

package info (click to toggle)
tldr-py 0.7.0-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 236 kB
  • sloc: python: 503; makefile: 13; sh: 13
file content (30 lines) | stat: -rw-r--r-- 1,016 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import absolute_import

from unittest import mock

from basic import BasicTestCase


class TestUpdate(BasicTestCase):
    def test_update_available(self):
        mock_different_sha1 = [
            '8f82e7445fef6cc83c2e02b82df5f92fe0a909c6',
            'a4013ab1b14812624bbddf96feb1bfa2b03564f6'
        ]
        self._assert_update_info(mock_different_sha1, 'Updating...')

    def test_no_need_for_update(self):
        mock_same_sha1 = [
            '8f82e7445fef6cc83c2e02b82df5f92fe0a909c6',
            '8f82e7445fef6cc83c2e02b82df5f92fe0a909c6'
        ]
        self._assert_update_info(mock_same_sha1, 'No need for updates.')

    def _assert_update_info(self, mock_sha1, expected_message):
        with mock.patch('subprocess.check_output', side_effect=mock_sha1):
            with mock.patch('subprocess.check_call', side_effect=[0, 0]):
                result = self.call_update_command()
        assert expected_message in result.output