def test_2_tags(self): post = 'This is a post with one #tag(with: args) and #another(tag: yay)' tags_and_args = parser.find_all_keywords_with_args(post) self.assertEqual(tags_and_args, { 'tag': [{ 'with': 'args' }], 'another': [{ 'tag': 'yay' }] })
def create(user_id, post_title, post_body): posted_keywords = parser.find_all_keywords_with_args(post_body) user_keywords_rs = user_keyword_resource.get_all_keywords_with_args(user_id) posted_keywords_rs = _construct_posted_keywords(posted_keywords, user_keywords_rs) post = Post( user_id=user_id, text=post_body, header=post_title, datetime=datetime.datetime.now(), posted_keywords=posted_keywords_rs, ) db.add(post) db.commit()
def create(user_id, post_title, post_body): posted_keywords = parser.find_all_keywords_with_args(post_body) user_keywords_rs = user_keyword_resource.get_all_keywords_with_args( user_id) posted_keywords_rs = _construct_posted_keywords(posted_keywords, user_keywords_rs) post = Post( user_id=user_id, text=post_body, header=post_title, datetime=datetime.datetime.now(), posted_keywords=posted_keywords_rs, ) db.add(post) db.commit() return post
def trailing_hash(self): post = 'This has a trailing #' tags_and_args = parser.find_all_keywords_with_args(post) self.assertEqual(tags_and_args, {})
def floating_hash(self): post = 'This has a floating # in the middle' tags_and_args = parser.find_all_keywords_with_args(post) self.assertEqual(tags_and_args, {})
def test_2_tags(self): post = 'This is a post with one #tag(with: args) and #another(tag: yay)' tags_and_args = parser.find_all_keywords_with_args(post) self.assertEqual(tags_and_args, {'tag': [{'with': 'args'}], 'another': [{'tag': 'yay'}]})
def test_1_tag_distracting_parens(self): post = 'This is ) a post ( with one #tag(with: args) ) (' tags_and_args = parser.find_all_keywords_with_args(post) self.assertEqual(tags_and_args, {'tag': [{'with': 'args'}]})
def test_1_tag_with_args(self): post = 'This is a post with one #tag(with: args)' tags_and_args = parser.find_all_keywords_with_args(post) self.assertEqual(tags_and_args, {'tag': [{'with': 'args'}]})
def test_1_tag_no_args(self): post = 'This is a post with one #tag without args' tags_and_args = parser.find_all_keywords_with_args(post) self.assertEqual(tags_and_args, {'tag': [{}]})
def test_no_tags(self): post = 'This is a post without any tags whatsoever' tags_and_args = parser.find_all_keywords_with_args(post) self.assertEqual(tags_and_args, {})
def trailing_hash(self): post = 'This has a trailing #' tags_and_args = parser.find_all_keywords_with_args(post) self.assertEqual(tags_and_args, {})
def floating_hash(self): post = 'This has a floating # in the middle' tags_and_args = parser.find_all_keywords_with_args(post) self.assertEqual(tags_and_args, {})
def test_1_tag_distracting_parens(self): post = 'This is ) a post ( with one #tag(with: args) ) (' tags_and_args = parser.find_all_keywords_with_args(post) self.assertEqual(tags_and_args, {'tag': [{'with': 'args'}]})
def test_1_tag_with_args(self): post = 'This is a post with one #tag(with: args)' tags_and_args = parser.find_all_keywords_with_args(post) self.assertEqual(tags_and_args, {'tag': [{'with': 'args'}]})
def test_1_tag_no_args(self): post = 'This is a post with one #tag without args' tags_and_args = parser.find_all_keywords_with_args(post) self.assertEqual(tags_and_args, {'tag': [{}]})
def test_no_tags(self): post = 'This is a post without any tags whatsoever' tags_and_args = parser.find_all_keywords_with_args(post) self.assertEqual(tags_and_args, {})