Nekmo / telegram-upload

@@ -14,7 +14,7 @@
Loading
14 14
15 15
from telegram_upload.config import SESSION_FILE
16 16
from telegram_upload.exceptions import ThumbError, TelegramUploadDataLoss, TelegramUploadNoSpaceError, \
17 -
    TelegramProxyError, TelegramInvalidFile
17 +
    TelegramProxyError, TelegramInvalidFile, MissingFileError
18 18
from telegram_upload.files import get_file_attributes, get_file_thumb, File
19 19
from telethon.version import __version__ as telethon_version
20 20
from telethon import TelegramClient
@@ -106,7 +106,9 @@
Loading
106 106
107 107
    def send_files(self, entity, files, delete_on_success=False, print_file_id=False,
108 108
                   force_file=False, forward=(), caption=None, thumbnail=None):
109 +
        has_files = False
109 110
        for file in files:
111 +
            has_files = True
110 112
            if isinstance(file, File):
111 113
                name = file_name = file.file_name
112 114
                file_size = file.file_size
@@ -155,6 +157,8 @@
Loading
155 157
                click.echo('Deleting "{}"'.format(file))
156 158
                os.remove(file)
157 159
            self.forward_to(message, forward)
160 +
        if not has_files:
161 +
            raise MissingFileError('Files do not exist.')
158 162
159 163
    def find_files(self, entity):
160 164
        for message in self.iter_messages(entity):

@@ -28,6 +28,10 @@
Loading
28 28
        return msg
29 29
30 30
31 +
class MissingFileError(TelegramUploadError):
32 +
    pass
33 +
34 +
31 35
class TelegramInvalidFile(TelegramUploadError):
32 36
    error_code = 3
33 37

@@ -19,12 +19,10 @@
Loading
19 19
        m.assert_called_once()
20 20
        m.return_value.send_files.assert_called_once()
21 21
22 -
    @patch('telegram_upload.management.Client')
23 -
    def test_failed(self, m):
22 +
    def test_missing_file(self):
24 23
        runner = CliRunner()
25 24
        result = runner.invoke(upload, ['missing_file.txt'])
26 25
        self.assertEqual(result.exit_code, 1)
27 -
        m.return_value.send_files.assert_not_called()
28 26
29 27
    @patch('telegram_upload.management.Client')
30 28
    def test_exclusive(self, m):
Files Coverage
telegram_upload 87.21%
tests 100.00%
Project Totals (17 files) 91.92%

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading