# vim: set filencoding=utf8 """ Activity Parser Test Suite @author: Mike Crute (mcrute@ag.com) @organization: American Greetings Interactive @date: February 04, 2010 """ from nose.tools import assert_equals from kronos.parser import parse_activity class TestWhenParsingBasicFormat(object): def test_should_get_activity(self): results = parse_activity("my activity@Home, Some cool stuff!") assert_equals(results.activity, "my activity") results = parse_activity("my activity") assert_equals(results.activity, "my activity") results = parse_activity("my activity@Home") assert_equals(results.activity, "my activity") results = parse_activity("my activity, Some cool stuff!") assert_equals(results.activity, "my activity") def test_should_get_description(self): results = parse_activity("my activity@Home, Some cool stuff!") assert_equals(results.description, "Some cool stuff!") results = parse_activity("my activity, Some cool stuff!") assert_equals(results.description, "Some cool stuff!") results = parse_activity("my activity") assert_equals(results.description, None) def test_should_get_category(self): results = parse_activity("my activity@Home, Some cool stuff!") assert_equals(results.category, "Home") results = parse_activity("my activity, Some cool stuff!") assert_equals(results.category, None) results = parse_activity("my activity@Home") assert_equals(results.category, "Home") class TestWhenParsingWithTags(object): def setup(self): test_input = "my activity@Home, Some cool stuff! #tag1 #tag2" self.results = parse_activity(test_input) def test_should_get_tags(self): assert_equals(self.results.tags, ['tag1', 'tag2']) def test_should_not_include_tags_in_description(self): assert_equals(self.results.description, "Some cool stuff!") # TODO: Implement this functionality when I need it. class TestWhenParsingWithTimeOffset(object): def test_should_understand_minutes(self): test_input = "my activity@Home, Some cool stuff! 10m" test_input = "my activity@Home, Some cool stuff! 10M" def test_should_understand_hours(self): test_input = "my activity@Home, Some cool stuff! 10h" test_input = "my activity@Home, Some cool stuff! 10H" def test_should_understand_seconds(self): test_input = "my activity@Home, Some cool stuff! 10s" test_input = "my activity@Home, Some cool stuff! 10S" class TestWhenParsingWithAbsoluteTime(object): def test_should_understand_military_time(self): test_input = "my activity@Home, Some cool stuff! 11:30-14:40" def test_should_understand_simple_time(self): test_input = "my activity@Home, Some cool stuff! 11:30AM-2:40PM" test_input = "my activity@Home, Some cool stuff! 11:30A-2:40P"