diff --git a/features/data/journals/dayone2.json b/features/data/journals/dayone2.json index ab9ba24f..dba50f3e 100644 --- a/features/data/journals/dayone2.json +++ b/features/data/journals/dayone2.json @@ -5,7 +5,7 @@ "creationDate": "2020-01-10T12:22:12Z", "photos": [], "starred": false, - "tags": [], + "tags": ["awesome", "great"], "text": "Entry Number One.", "timeZone": "Europe/London", "uuid": "EBB5A5F4057F461E8F176E18AB7E0493" @@ -15,7 +15,7 @@ "creationDate": "2020-01-10T12:21:48Z", "photos": [], "starred": true, - "tags": [], + "tags": ["great"], "text": "Entry Number Two.\n\nWith some body.", "timeZone": "Europe/London", "uuid": "EC61E5D4E66C44E6AC796E863E8BF7E7" diff --git a/features/dayone2.feature b/features/dayone2.feature index 9ec5ccdb..30b9024d 100644 --- a/features/dayone2.feature +++ b/features/dayone2.feature @@ -23,11 +23,18 @@ Feature: Day One 2.0 implementation details. Scenario: Converted journal is validated 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. + Then we should get no error + When we run "jrnl dayone2 -n 2" + Then we should get no error + and the output should contain "10-01-2020 12:21 Entry Number Two." - 10-01-2020 12:22 Entry Number One. + Scenario: Check tags are handled correctly + Given we use the config "basic.yaml" + When we run "jrnl --import dayone2 features/data/journals/dayone2.json" + When we run "jrnl dayone2 --tags" + Then we should get no error + and the output should contain + """ + @great : 2 + @awesome : 1 """ \ No newline at end of file diff --git a/jrnl/plugins/dayone2_importer.py b/jrnl/plugins/dayone2_importer.py index cb921805..67bb8d70 100644 --- a/jrnl/plugins/dayone2_importer.py +++ b/jrnl/plugins/dayone2_importer.py @@ -26,7 +26,7 @@ class DayOne2Importer(JSONImporter): self.convert_journal() def convert_journal(self): - print(self._convert()) + self._convert() def validate_schema(self): try: @@ -42,13 +42,14 @@ class DayOne2Importer(JSONImporter): def parse_json(self): entries = [] - print(self.json) for entry in self.json["entries"]: + tags = " ".join(["@" + t for t in entry["tags"]]) + entries.append( Entry( self, date=datetime.strptime(entry["creationDate"], "%Y-%m-%dT%H:%M:%SZ"), - text=entry["text"], + text=f"{entry['text']} {tags}", starred=entry["starred"], ) )