style fixes for GitHub actions

This commit is contained in:
MinchinWeb 2021-05-09 14:22:50 -06:00
parent c8ca3a0358
commit e1d2f873da
4 changed files with 38 additions and 42 deletions

View file

@ -2,7 +2,6 @@
import json
from jrnl.plugins.base import BaseExporter
from jrnl.plugins.util import get_tags_count
__version__ = "v1.0.0"
@ -32,7 +31,6 @@ class Exporter(BaseExporter):
@classmethod
def export_journal(cls, journal):
"""Returns a json representation of an entire journal."""
tags = get_tags_count(journal)
result = {
"entries": [cls.entry_to_dict(e) for e in journal.entries],
}

View file

@ -6,37 +6,41 @@ import pytest
from jrnl import Entry
from jrnl import Journal
from jrnl.plugins.exporter import json as json_exporter
from jrnl.plugins.exporter import testing as testing_exporter
try:
from jrnl.contrib.exporter import testing as testing_exporter
except:
testing_exporter = None
@pytest.fixture()
def create_entry():
entry = Entry.Entry(
journal=Journal.Journal(),
text="This is the entry text",
date=date(year=2001, month=1, day=1),
starred=True,
)
yield entry
if testing_exporter:
@pytest.fixture()
def create_entry():
entry = Entry.Entry(
journal=Journal.Journal(),
text="This is the entry text",
date=date(year=2001, month=1, day=1),
starred=True,
)
yield entry
class TestBaseExporter(testing_exporter.Exporter):
def test_unimplemented_export(self, create_entry):
entry = create_entry
with pytest.raises(NotImplementedError):
self.export_entry(entry)
class TestBaseExporter(testing_exporter.Exporter):
def test_unimplemented_export(self, create_entry):
entry = create_entry
with pytest.raises(NotImplementedError):
self.export_entry(entry)
class TestJsonExporter(json_exporter.Exporter):
def test_json_exporter_name(self):
assert "json" in self.names
class TestJsonExporter(json_exporter.Exporter):
def test_json_exporter_name(self):
assert "json" in self.names
def test_export_entry(self, create_entry):
entry = create_entry
fake_uuid = "ewqf09-432p9p0433-243209" # generated by mashing keys
entry.uuid = fake_uuid
exported = self.export_entry(entry)
deserialized_export = json.loads(exported)
assert deserialized_export["title"] == "This is the entry text"
assert deserialized_export["date"] == "2001-01-01"
assert "uuid" in deserialized_export.keys()
def test_export_entry(self, create_entry):
entry = create_entry
fake_uuid = "ewqf09-432p9p0433-243209" # generated by mashing keys
entry.uuid = fake_uuid
exported = self.export_entry(entry)
deserialized_export = json.loads(exported)
assert deserialized_export["title"] == "This is the entry text"
assert deserialized_export["date"] == "2001-01-01"
assert "uuid" in deserialized_export.keys()