From 788b32b71c9cab1681c969133ffa81fc12451c3b Mon Sep 17 00:00:00 2001 From: Suhas Date: Thu, 6 May 2021 15:12:48 -0400 Subject: [PATCH] make format delete unused imports --- features/steps/core.py | 1 + jrnl/plugins/base.py | 1 - jrnl/plugins/exporter/testing_exporter.py | 8 +++---- jrnl/plugins/exporter/text_exporter.py | 1 - jrnl/plugins/util.py | 1 + tests/test_plugin.py | 28 ++++++++++++++++------- 6 files changed, 26 insertions(+), 14 deletions(-) diff --git a/features/steps/core.py b/features/steps/core.py index 89a00559..6c1f8556 100644 --- a/features/steps/core.py +++ b/features/steps/core.py @@ -461,6 +461,7 @@ def run(context, command, text=""): @given('we load template "{filename}"') def load_template(context, filename): full_path = os.path.join("features/data/templates", filename) + exporter = plugins.template_exporter.__exporter_from_file(full_path) plugins.meta.__exporter_types[exporter.names[0]] = exporter diff --git a/jrnl/plugins/base.py b/jrnl/plugins/base.py index e7a3dee0..2497c52b 100644 --- a/jrnl/plugins/base.py +++ b/jrnl/plugins/base.py @@ -12,7 +12,6 @@ import os import re import unicodedata -from jrnl import __version__ from jrnl.color import ERROR_COLOR from jrnl.color import RESET_COLOR diff --git a/jrnl/plugins/exporter/testing_exporter.py b/jrnl/plugins/exporter/testing_exporter.py index 0520d541..c88314e8 100644 --- a/jrnl/plugins/exporter/testing_exporter.py +++ b/jrnl/plugins/exporter/testing_exporter.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python # encoding: utf-8 # Copyright (C) 2012-2021 jrnl contributors # License: https://www.gnu.org/licenses/gpl-3.0.html @@ -7,9 +7,9 @@ Exporter for testing and experimentation purposes """ -from jrnl import __version__ from jrnl.plugins.base import BaseExporter + class Exporter(BaseExporter): - names=["testing","test"] - version= 'v0.0.1' \ No newline at end of file + names = ["testing", "test"] + version = "v0.0.1" diff --git a/jrnl/plugins/exporter/text_exporter.py b/jrnl/plugins/exporter/text_exporter.py index 91580dcc..20339922 100644 --- a/jrnl/plugins/exporter/text_exporter.py +++ b/jrnl/plugins/exporter/text_exporter.py @@ -3,7 +3,6 @@ # Copyright (C) 2012-2021 jrnl contributors # License: https://www.gnu.org/licenses/gpl-3.0.html -from jrnl import __version__ from jrnl.plugins.base import BaseExporter from ... import __version__ diff --git a/jrnl/plugins/util.py b/jrnl/plugins/util.py index c5d16529..284c3a96 100644 --- a/jrnl/plugins/util.py +++ b/jrnl/plugins/util.py @@ -3,6 +3,7 @@ # Copyright (C) 2012-2021 jrnl contributors # License: https://www.gnu.org/licenses/gpl-3.0.html + def get_tags_count(journal): """Returns a set of tuples (count, tag) for all tags present in the journal.""" # Astute reader: should the following line leave you as puzzled as me the first time diff --git a/tests/test_plugin.py b/tests/test_plugin.py index e4c413c7..33c7f1ce 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -5,23 +5,35 @@ 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) + 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): + +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): + + +class TestJsonExporter(json_exporter.Exporter): + def test_json_exporter_name(self): assert "json" in self.names - def test_export_entry(self,create_entry): + 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' \ No newline at end of file + assert deserialized_export["title"] == "This is the entry text" + assert deserialized_export["date"] == "2001-01-01" + assert "uuid" in deserialized_export.keys()