mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-18 20:18:32 +02:00
prototype unittest for JSON Exporter
test for unimplemented method
This commit is contained in:
parent
6c6929bbbf
commit
c76b9788e6
1 changed files with 27 additions and 0 deletions
27
tests/test_plugin.py
Normal file
27
tests/test_plugin.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
import pytest
|
||||
|
||||
from jrnl.plugins.exporter import testing_exporter, json_exporter
|
||||
from jrnl import Entry, Journal
|
||||
from datetime import date
|
||||
import json
|
||||
|
||||
@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 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
|
||||
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'
|
Loading…
Add table
Reference in a new issue