mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-07-06 16:26:13 +02:00
add tests
This commit is contained in:
parent
774355971a
commit
16a4e60582
4 changed files with 20 additions and 14 deletions
|
@ -16,7 +16,7 @@
|
||||||
"photos": [],
|
"photos": [],
|
||||||
"starred": true,
|
"starred": true,
|
||||||
"tags": [],
|
"tags": [],
|
||||||
"text": "Entry Number Two.\n\nAnd a bit of text over here.",
|
"text": "Entry Number Two.\n\nWith some body.",
|
||||||
"timeZone": "Europe/London",
|
"timeZone": "Europe/London",
|
||||||
"uuid": "EC61E5D4E66C44E6AC796E863E8BF7E7"
|
"uuid": "EC61E5D4E66C44E6AC796E863E8BF7E7"
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,15 +13,21 @@ Feature: Day One 2.0 implementation details.
|
||||||
Then we should get no error
|
Then we should get no error
|
||||||
and the output should contain "not the expected Day One 2 format."
|
and the output should contain "not the expected Day One 2 format."
|
||||||
|
|
||||||
Scenario: Verify conversion to jrnl
|
Scenario: Converted journal is added to config
|
||||||
Given we use the config "basic.yaml"
|
Given we use the config "basic.yaml"
|
||||||
When we run "jrnl --import dayone2 features/data/journals/dayone2.json"
|
When we run "jrnl --import dayone2 features/data/journals/dayone2.json"
|
||||||
When we run "jrnl -ls"
|
When we run "jrnl -ls"
|
||||||
Then the output should be
|
Then the output should contain "dayone2.txt"
|
||||||
"""
|
And the output should contain "default"
|
||||||
2013-06-09 15:39 My first entry.
|
|
||||||
| Everything is alright
|
|
||||||
|
|
||||||
2013-06-10 15:40 Life is good.
|
Scenario: Converted journal is validated
|
||||||
| But I'm better.
|
Given we use the config "basic.yaml"
|
||||||
|
When we run "jrnl --import dayone2 features/data/journals/dayone2.json"
|
||||||
|
When we run "jrnl dayone2 -n 10"
|
||||||
|
Then the output should contain
|
||||||
|
"""
|
||||||
|
10-01-2020 12:21 Entry Number Two.
|
||||||
|
| With some body.
|
||||||
|
|
||||||
|
10-01-2020 12:22 Entry Number One.
|
||||||
"""
|
"""
|
|
@ -10,7 +10,7 @@ class DayOne2Importer(JSONImporter):
|
||||||
extension = "json"
|
extension = "json"
|
||||||
|
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
self.type = "DayOne2"
|
self.type = "dayone2"
|
||||||
self.path = path
|
self.path = path
|
||||||
self.keys = [
|
self.keys = [
|
||||||
"audios",
|
"audios",
|
||||||
|
@ -42,6 +42,7 @@ class DayOne2Importer(JSONImporter):
|
||||||
|
|
||||||
def parse_json(self):
|
def parse_json(self):
|
||||||
entries = []
|
entries = []
|
||||||
|
print(self.json)
|
||||||
for entry in self.json["entries"]:
|
for entry in self.json["entries"]:
|
||||||
entries.append(
|
entries.append(
|
||||||
Entry(
|
Entry(
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
|
from jrnl.install import CONFIG_FILE_PATH, save_config
|
||||||
from jrnl.util import load_config
|
from jrnl.util import load_config
|
||||||
from jrnl.install import CONFIG_FILE_PATH, CONFIG_FILE_PATH_FALLBACK
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
def get_tags_count(journal):
|
def get_tags_count(journal):
|
||||||
|
@ -34,9 +35,7 @@ def add_journal_to_config(name, path):
|
||||||
try:
|
try:
|
||||||
data = load_config(CONFIG_FILE_PATH)
|
data = load_config(CONFIG_FILE_PATH)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
try:
|
print("Config file not found.")
|
||||||
data = load_config(CONFIG_FILE_PATH_FALLBACK)
|
|
||||||
except FileNotFoundError:
|
|
||||||
print("Config file not found.")
|
|
||||||
finally:
|
finally:
|
||||||
data["journals"][name] = path
|
data["journals"][name] = path
|
||||||
|
save_config(data)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue