blob: 5fccfc09914c916c827ec2cdfee45a3430fecc3a (
plain)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# wikiget - CLI tool for downloading files from Wikimedia sites
# Copyright (C) 2023 Cody Logan
# SPDX-License-Identifier: GPL-3.0-or-later
#
# Wikiget is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Wikiget is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Wikiget. If not, see <https://www.gnu.org/licenses/>.
"""Define fixtures used across all tests in this folder."""
import pytest
import requests_mock as rm
from wikiget.file import File
@pytest.fixture()
def file_with_name() -> File:
"""Create a test File with only a filename.
A File object created with only a name should set its destination property to
the same value and its site property to the program's default site.
:return: File object created using a filename
:rtype: File
"""
return File("foobar.jpg")
@pytest.fixture()
def file_with_name_and_dest() -> File:
"""Create a test File with a name and destination.
:return: File object created with name and dest
:rtype: File
"""
return File(name="foobar.jpg", dest="bazqux.jpg")
@pytest.fixture()
def _mock_get(requests_mock: rm.Mocker) -> None:
"""Fake the download request for the true URL of File:Example.jpg.
:param requests_mock: a requests_mock Mocker object
:type requests_mock: rm.Mocker
"""
requests_mock.get(
"https://upload.wikimedia.org/wikipedia/commons/a/a9/Example.jpg",
text="data",
)
|