89 lines
2.4 KiB
Python
89 lines
2.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
# type: ignore
|
|
from __future__ import annotations
|
|
|
|
import csv
|
|
import datetime
|
|
import io
|
|
|
|
import pytest
|
|
|
|
from hotpocket_backend_testing.dto.ui import PocketImportSaveSpec
|
|
|
|
|
|
@pytest.fixture
|
|
def pocket_import_created_save_spec():
|
|
return PocketImportSaveSpec.model_validate({
|
|
'title': 'Ziomek',
|
|
'url': 'https://www.ziomek.dog/',
|
|
'time_added': datetime.datetime(
|
|
1985, 12, 12, 8, 0, 0, 0, tzinfo=datetime.UTC,
|
|
),
|
|
'tags': '',
|
|
'status': 'unread',
|
|
})
|
|
|
|
|
|
@pytest.fixture
|
|
def pocket_import_reused_save_spec(save_out):
|
|
return PocketImportSaveSpec.model_validate({
|
|
'title': save_out.title,
|
|
'url': save_out.url,
|
|
'time_added': datetime.datetime(
|
|
1987, 10, 3, 8, 0, 0, 0, tzinfo=datetime.UTC,
|
|
),
|
|
'tags': '',
|
|
'status': 'unread',
|
|
})
|
|
|
|
|
|
@pytest.fixture
|
|
def pocket_import_other_account_save_spec(other_account_save_out):
|
|
return PocketImportSaveSpec.model_validate({
|
|
'title': other_account_save_out.title,
|
|
'url': other_account_save_out.url,
|
|
'time_added': datetime.datetime(
|
|
2019, 12, 6, 8, 0, 0, 0, tzinfo=datetime.UTC,
|
|
),
|
|
'tags': '',
|
|
'status': 'unread',
|
|
})
|
|
|
|
|
|
@pytest.fixture
|
|
def pocket_import_banned_netloc_save_spec():
|
|
return PocketImportSaveSpec.model_validate({
|
|
'title': 'Nyan Cat! [Official]',
|
|
'url': 'https://www.youtube.com/watch?v=2yJgwwDcgV8',
|
|
'time_added': datetime.datetime(
|
|
2021, 9, 17, 8, 0, 0, 0, tzinfo=datetime.UTC,
|
|
),
|
|
'tags': '',
|
|
'status': 'unread',
|
|
})
|
|
|
|
|
|
@pytest.fixture
|
|
def pocket_csv_content(pocket_import_created_save_spec,
|
|
pocket_import_reused_save_spec,
|
|
pocket_import_other_account_save_spec,
|
|
pocket_import_banned_netloc_save_spec,
|
|
):
|
|
with io.StringIO() as csv_f:
|
|
field_names = [
|
|
'title', 'url', 'time_added', 'tags', 'status',
|
|
]
|
|
|
|
writer = csv.DictWriter(csv_f, field_names, dialect=csv.excel)
|
|
writer.writeheader()
|
|
writer.writerows([
|
|
pocket_import_created_save_spec.dict(),
|
|
pocket_import_reused_save_spec.dict(),
|
|
pocket_import_other_account_save_spec.dict(),
|
|
pocket_import_banned_netloc_save_spec.dict(),
|
|
])
|
|
|
|
csv_f.seek(0)
|
|
|
|
yield csv_f.getvalue()
|