fimfarchive/tests/conftest.py

73 lines
1.6 KiB
Python
Raw Normal View History

2016-12-19 00:10:31 +01:00
"""
Configuration for tests.
"""
#
# Fimfarchive, preserves stories from Fimfiction.
# Copyright (C) 2015 Joakim Soderlund
#
# This program 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.
#
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
#
from unittest.mock import MagicMock
import pytest
from fimfarchive.fetchers import Fetcher
2016-12-19 00:26:24 +01:00
from fimfarchive.flavors import Flavor
2017-01-08 01:40:49 +01:00
from fimfarchive.stories import Story
2016-12-19 00:10:31 +01:00
@pytest.fixture
def fetcher():
"""
Returns a parially mocked fetcher instance.
"""
fetcher = Fetcher()
2018-08-04 22:19:52 +02:00
fetcher.fetch_meta = MagicMock(method='fetch_meta') # type: ignore
fetcher.fetch_data = MagicMock(method='fetch_data') # type: ignore
2016-12-19 00:10:31 +01:00
return fetcher
2016-12-19 00:26:24 +01:00
@pytest.fixture
def flavor():
"""
Returns a flavor with A and B members.
"""
class MyFlavor(Flavor):
A = ()
B = ()
return MyFlavor
2017-01-08 01:40:49 +01:00
@pytest.fixture
def story(flavor):
"""
Returns a non-lazy dummy story.
"""
story = Story(
key=1,
fetcher=None,
meta={'id': 1},
data=b'<html />',
flavors={flavor.A},
)
return story