Skip to content

Commit

Permalink
Add tests for the local aliases feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylvain Fankhauser committed Jul 30, 2014
1 parent ae744fd commit 7352851
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tests/commands/test_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@freeze_time('2014-01-20')
class CommitCommandTestCase(CommandTestCase):
def test_commit(self):
config = self.default_config
config = self.default_config.copy()
config['wrmap']['fail'] = '456/789'

self.write_entries("""20/01/2014
Expand All @@ -22,3 +22,14 @@ def test_commit(self):
lines = entries.readlines()

self.assertEqual(lines[4], 'fail 09:15-11:45 Make printer work\n')

def test_local_alias(self):
config = self.default_config.copy()
config['default']['local_aliases'] = '_pingpong'

self.write_entries("""20/01/2014
_pingpong 0800-0900 Play ping-pong
""")

stdout = self.run_command('commit', options=self.default_options)
self.assertIn("Total pushed 0.00", stdout)
39 changes: 39 additions & 0 deletions tests/commands/test_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from freezegun import freeze_time

from . import CommandTestCase


@freeze_time('2014-01-20')
class StatusCommandTestCase(CommandTestCase):
def test_local_alias(self):
config = self.default_config.copy()
config['default']['local_aliases'] = '_pingpong'

self.write_entries("""20/01/2014
_pingpong 0800-0900 Play ping-pong
""")
stdout = self.run_command('status', options=self.default_options)

self.assertIn(
"_pingpong (local) 1.00 Play ping-pong",
stdout
)

def test_multiple_local_aliases(self):
config = self.default_config.copy()
config['default']['local_aliases'] = '_pingpong, _coffee'

self.write_entries("""20/01/2014
_pingpong 0800-0900 Play ping-pong
_coffee 0900-1000 Drink some coffee
""")

stdout = self.run_command('status', options=self.default_options)
self.assertIn(
"_pingpong (local) 1.00 Play ping-pong",
stdout
)
self.assertIn(
"_coffee (local) 1.00 Drink some coffee",
stdout
)

0 comments on commit 7352851

Please sign in to comment.