Skip to content

Commit

Permalink
Add worflows - tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lbesnard committed Oct 17, 2024
1 parent 3044bcc commit e6f8466
Showing 1 changed file with 34 additions and 22 deletions.
56 changes: 34 additions & 22 deletions test_koreader_highlights_2_anki/test_main.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import os
import unittest

from koreader_highlights_2_anki.__main__ import parse_lua_highlights_annotations, parse_lua_highlights_bookmarks
from koreader_highlights_2_anki.__main__ import (
parse_lua_highlights_annotations,
parse_lua_highlights_bookmarks,
)

ROOT_DIR = os.path.dirname(os.path.abspath(__file__))


class TestParseLuaHighlightsAnnotations(unittest.TestCase):

def test_parse_lua_highlights_annotations(self):
# Define the path to the Lua file
filepath = os.path.join("Ali Abdaal - Feel-Good Productivity_ How to Do More of What Matters to You.sdr/metadata.epub.lua")
filepath = os.path.join(
"Ali Abdaal - Feel-Good Productivity_ How to Do More of What Matters to You.sdr/metadata.epub.lua"
)
filepath = os.path.join(ROOT_DIR, "resources", filepath)

# Call the function with the actual Lua file
Expand All @@ -22,16 +26,20 @@ def test_parse_lua_highlights_annotations(self):
"authors": "Abdaal, Ali",
"language": "en-US",
"entries": [
{'chapter': 'Introduction',
'datetime': '2024-08-30 12:31:05',
'notes': 'when we’re in a positive mood, we tend to consider a broader range '
'of actions, be more open to new experiences, and better integrate '
'the information we receive',
'page': 14},
{'chapter': 'Introduction',
'datetime': '2024-08-30 12:31:27',
'notes': 'feeling good boosts our creativity –',
'page': 15}
{
"chapter": "Introduction",
"datetime": "2024-08-30 12:31:05",
"notes": "when we’re in a positive mood, we tend to consider a broader range "
"of actions, be more open to new experiences, and better integrate "
"the information we receive",
"page": 14,
},
{
"chapter": "Introduction",
"datetime": "2024-08-30 12:31:27",
"notes": "feeling good boosts our creativity –",
"page": 15,
},
],
}

Expand All @@ -43,7 +51,9 @@ def test_parse_lua_highlights_annotations(self):

def test_parse_lua_highlights_bookmarks(self):
# Define the path to the Lua file
filepath = os.path.join("Wallace J. Nichols - Blue Mind_ How Water Makes You Happier_ More Connected and Better at What You Do.sdr/metadata.epub.lua")
filepath = os.path.join(
"Wallace J. Nichols - Blue Mind_ How Water Makes You Happier_ More Connected and Better at What You Do.sdr/metadata.epub.lua"
)
filepath = os.path.join(ROOT_DIR, "resources", filepath)

# Call the function with the actual Lua file
Expand All @@ -55,13 +65,15 @@ def test_parse_lua_highlights_bookmarks(self):
"authors": "Céline Cousteau\nWallace J. Nichols",
"language": "en",
"entries": [
{'chapter': '3. The Water Premium',
'datetime': '2021-02-15 14:28:25',
'notes': 'The factors that help boost Ryan Howell’s happiness for the longer '
'term are the pursuit and attainment of personal goals and the '
'adoption of meaningful activities. Suppose that Howell was '
'planning',
'page': '12'}
{
"chapter": "3. The Water Premium",
"datetime": "2021-02-15 14:28:25",
"notes": "The factors that help boost Ryan Howell’s happiness for the longer "
"term are the pursuit and attainment of personal goals and the "
"adoption of meaningful activities. Suppose that Howell was "
"planning",
"page": "12",
}
],
}

Expand All @@ -72,5 +84,5 @@ def test_parse_lua_highlights_bookmarks(self):
self.assertEqual(result["entries"], expected_metadata["entries"])


if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()

0 comments on commit e6f8466

Please sign in to comment.