예제 #1
0
 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'
         }]
     })
예제 #2
0
파일: post.py 프로젝트: dnlk/keywordjournal
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()
예제 #3
0
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
예제 #4
0
 def trailing_hash(self):
     post = 'This has a trailing #'
     tags_and_args = parser.find_all_keywords_with_args(post)
     self.assertEqual(tags_and_args, {})
예제 #5
0
 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, {})
예제 #6
0
 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'}]})
예제 #7
0
 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'}]})
예제 #8
0
 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'}]})
예제 #9
0
 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': [{}]})
예제 #10
0
 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, {})
예제 #11
0
 def trailing_hash(self):
     post = 'This has a trailing #'
     tags_and_args = parser.find_all_keywords_with_args(post)
     self.assertEqual(tags_and_args, {})
예제 #12
0
 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, {})
예제 #13
0
 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'}]})
예제 #14
0
 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'}]})
예제 #15
0
 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': [{}]})
예제 #16
0
 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, {})