Core testing

This commit is contained in:
Manuel Ebert 2013-07-18 22:49:22 +02:00
parent b2b842711d
commit 47c90b6d40
4 changed files with 57 additions and 0 deletions

View 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
View 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.
"""

View 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
View 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()