# 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 test_should_get_tags(self): test = parse_activity("my activity@Home, Some cool stuff! #tag1 #tag2") assert_equals(test.tags, ['tag1', 'tag2']) def test_should_not_include_tags_in_description(self): test = parse_activity("my activity@Home, Some cool stuff! #tag1 #tag2") assert_equals(test.description, "Some cool stuff!") def test_should_not_include_tags_in_category(self): test = parse_activity("my activity@Home #tag1 #tag2") assert_equals(test.tags, ['tag1', 'tag2']) assert_equals(test.category, 'Home')