mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
Core testing
This commit is contained in:
parent
b2b842711d
commit
47c90b6d40
4 changed files with 57 additions and 0 deletions
14
features/configs/basic.json
Normal file
14
features/configs/basic.json
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"default_hour": 9,
|
||||||
|
"timeformat": "%Y-%m-%d %H:%M",
|
||||||
|
"linewrap": 80,
|
||||||
|
"encrypt": false,
|
||||||
|
"editor": "",
|
||||||
|
"default_minute": 0,
|
||||||
|
"highlight": true,
|
||||||
|
"password": "",
|
||||||
|
"journals": {
|
||||||
|
"default": "features/journals/simple.journal"
|
||||||
|
},
|
||||||
|
"tagsymbols": "@"
|
||||||
|
}
|
14
features/core.feature
Normal file
14
features/core.feature
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
Feature: Basic reading and writing to a journal
|
||||||
|
|
||||||
|
Scenario: Loading a sample journal
|
||||||
|
Given we use "basic.json"
|
||||||
|
When we run "jrnl -n 2"
|
||||||
|
Then we should get no error
|
||||||
|
Then the output should be
|
||||||
|
"""
|
||||||
|
2013-06-09 15:39 My first entry.
|
||||||
|
| Everything is alright
|
||||||
|
|
||||||
|
2013-06-10 15:40 Life is good.
|
||||||
|
| But I'm better.
|
||||||
|
"""
|
5
features/journals/simple.journal
Normal file
5
features/journals/simple.journal
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
2013-06-09 15:39 My first entry.
|
||||||
|
Everything is alright
|
||||||
|
|
||||||
|
2013-06-10 15:40 Life is good.
|
||||||
|
But I'm better.
|
24
features/steps/core.py
Normal file
24
features/steps/core.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
from behave import *
|
||||||
|
from jrnl import Journal, jrnl
|
||||||
|
import os
|
||||||
|
|
||||||
|
@given('we use "{config_file}"')
|
||||||
|
def set_config(context, config_file):
|
||||||
|
full_path = os.path.join("features/configs", config_file)
|
||||||
|
jrnl.CONFIG_PATH = os.path.abspath(full_path)
|
||||||
|
|
||||||
|
@when('we run "{command}"')
|
||||||
|
def run(context, command):
|
||||||
|
args = command.split()[1:]
|
||||||
|
jrnl.cli(args)
|
||||||
|
|
||||||
|
@then('we should get no error')
|
||||||
|
def no_error(context):
|
||||||
|
assert context.failed is False
|
||||||
|
|
||||||
|
@then('the output should be')
|
||||||
|
def check_output(context):
|
||||||
|
text = context.text.strip().splitlines()
|
||||||
|
out = context.stdout_capture.getvalue().strip().splitlines()
|
||||||
|
for line_text, line_out in zip(text, out):
|
||||||
|
assert line_text.strip() == line_out.strip()
|
Loading…
Add table
Reference in a new issue