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

@ -32,11 +32,6 @@ jobs:
python-version: 3.9 python-version: 3.9
steps: steps:
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }} - name: Set up Python ${{ matrix.python-version }}
@ -56,7 +51,7 @@ jobs:
poetry config --local virtualenvs.in-project true poetry config --local virtualenvs.in-project true
poetry install --remove-untracked poetry install --remove-untracked
poetry install poetry install
poetry run python -m pip install -e "git+${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git@{{ steps.extract_branch.outputs.branch }}#egg=jrnl-demo-plugins&subdirectory=tests/external_plugins_src" poetry run python -m pip install -e "git+${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git@${GITHUB_SHA}#egg=jrnl-demo-plugins&subdirectory=tests/external_plugins_src"
- name: Test with pytest - name: Test with pytest
if: success() || failure() if: success() || failure()

View file

@ -3,7 +3,6 @@
import ast import ast
from collections import defaultdict from collections import defaultdict
from jrnl.args import parse_args
import os import os
from pathlib import Path from pathlib import Path
import re import re
@ -14,20 +13,20 @@ from behave import given
from behave import then from behave import then
from behave import when from behave import when
import keyring import keyring
import toml import toml
import yaml import yaml
from yaml.loader import FullLoader from yaml.loader import FullLoader
import jrnl.time
from jrnl import Journal from jrnl import Journal
from jrnl import __version__ from jrnl import __version__
from jrnl import plugins from jrnl import plugins
from jrnl.args import parse_args
from jrnl.cli import cli from jrnl.cli import cli
from jrnl.config import load_config from jrnl.config import load_config
from jrnl.os_compat import split_args from jrnl.os_compat import split_args
from jrnl.override import apply_overrides, _recursively_apply from jrnl.override import _recursively_apply
from jrnl.override import apply_overrides
import jrnl.time
try: try:
import parsedatetime.parsedatetime_consts as pdt import parsedatetime.parsedatetime_consts as pdt

View file

@ -2,7 +2,6 @@
import json import json
from jrnl.plugins.base import BaseExporter from jrnl.plugins.base import BaseExporter
from jrnl.plugins.util import get_tags_count
__version__ = "v1.0.0" __version__ = "v1.0.0"
@ -32,7 +31,6 @@ class Exporter(BaseExporter):
@classmethod @classmethod
def export_journal(cls, journal): def export_journal(cls, journal):
"""Returns a json representation of an entire journal.""" """Returns a json representation of an entire journal."""
tags = get_tags_count(journal)
result = { result = {
"entries": [cls.entry_to_dict(e) for e in journal.entries], "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 Entry
from jrnl import Journal from jrnl import Journal
from jrnl.plugins.exporter import json as json_exporter 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() if testing_exporter:
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
@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): class TestBaseExporter(testing_exporter.Exporter):
def test_unimplemented_export(self, create_entry): def test_unimplemented_export(self, create_entry):
entry = create_entry entry = create_entry
with pytest.raises(NotImplementedError): with pytest.raises(NotImplementedError):
self.export_entry(entry) 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_export_entry(self, create_entry):
def test_json_exporter_name(self): entry = create_entry
assert "json" in self.names fake_uuid = "ewqf09-432p9p0433-243209" # generated by mashing keys
entry.uuid = fake_uuid
def test_export_entry(self, create_entry): exported = self.export_entry(entry)
entry = create_entry deserialized_export = json.loads(exported)
fake_uuid = "ewqf09-432p9p0433-243209" # generated by mashing keys assert deserialized_export["title"] == "This is the entry text"
entry.uuid = fake_uuid assert deserialized_export["date"] == "2001-01-01"
exported = self.export_entry(entry) assert "uuid" in deserialized_export.keys()
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()