示例#1
0
 def test_gets_by_proj_and_ref(self):
     cid1 = comment.add(T_PROJ_ID, T_REF, T_AUTHOR, T_CONTENT)
     comment.add(T_PROJ_ID, T_REF_2, T_AUTHOR, T_CONTENT)
     cid2 = comment.add(T_PROJ_ID, T_REF, T_AUTHOR, T_CONTENT2)
     cmnts = comment.gets_by_proj_and_ref(T_PROJ_ID, T_REF,
                                          order='desc')[:2]
     assert cmnts == [cid2, cid1]
示例#2
0
 def test_gets_by_proj_and_ref(self):
     cid1 = comment.add(T_PROJ_ID, T_REF, T_AUTHOR, T_CONTENT)
     comment.add(T_PROJ_ID, T_REF_2, T_AUTHOR, T_CONTENT)
     cid2 = comment.add(T_PROJ_ID, T_REF, T_AUTHOR, T_CONTENT2)
     cmnts = comment.gets_by_proj_and_ref(
         T_PROJ_ID, T_REF, order='desc')[:2]
     assert cmnts == [cid2, cid1]
示例#3
0
 def test_delete_comment(self):
     cid = comment.add(T_PROJ_ID, T_REF, T_AUTHOR, T_CONTENT)
     assert comment.get(cid)
     ok = comment.delete(cid)
     assert ok
     assert not comment.get(cid)
     assert not comment.delete(cid), "Cannot delete twice same comment"
示例#4
0
 def test_delete_comment(self):
     cid = comment.add(T_PROJ_ID, T_REF, T_AUTHOR, T_CONTENT)
     assert comment.get(cid)
     ok = comment.delete(cid)
     assert ok
     assert not comment.get(cid)
     assert not comment.delete(cid), "Cannot delete twice same comment"
示例#5
0
 def test_gets_with_proj_with_order(self):
     all_cmnts = [comment.add(T_PROJ_ID, T_REF, T_AUTHOR, T_CONTENT)
                  for i in range(30)]
     assert len(all_cmnts) == 30
     assert comment.gets_by_proj_and_ref(
         T_PROJ_ID, T_REF, order='desc')[:30] == list(reversed(all_cmnts))
     assert comment.gets_by_proj_and_ref(
         T_PROJ_ID, T_REF, start=10, limit=5, order='desc') == all_cmnts[15:20][::-1]  # noqa
示例#6
0
 def test_gets_with_order(self):
     all_cmnts = [
         comment.add(T_PROJ_ID, T_REF, T_AUTHOR, T_CONTENT)
         for i in range(30)
     ]
     assert len(all_cmnts) == 30
     assert comment.gets_by_ref(T_REF, order='desc')[:30] == list(
         reversed(all_cmnts))
示例#7
0
 def test_gets_with_order(self):
     all_cmnts = [comment.add(T_PROJ_ID, T_REF, T_AUTHOR, T_CONTENT)
                  for i in range(30)]
     assert len(all_cmnts) == 30
     assert comment.gets_by_ref(
         T_REF, order='desc') == list(reversed(all_cmnts))
     assert comment.gets_by_ref(T_REF, start=10) == all_cmnts[10:]
     assert comment.gets_by_ref(
         T_REF, start=10, limit=5) == all_cmnts[10:15]
示例#8
0
 def test_gets_with_proj_with_order(self):
     all_cmnts = [
         comment.add(T_PROJ_ID, T_REF, T_AUTHOR, T_CONTENT)
         for i in range(30)
     ]
     assert len(all_cmnts) == 30
     assert comment.gets_by_proj_and_ref(T_PROJ_ID, T_REF,
                                         order='desc')[:30] == list(
                                             reversed(all_cmnts))
     assert comment.gets_by_proj_and_ref(
         T_PROJ_ID, T_REF, start=10, limit=5,
         order='desc') == all_cmnts[15:20][::-1]  # noqa
示例#9
0
 def test_latest_comments(self):
     cid1 = comment.add(T_PROJ_ID, T_REF, T_AUTHOR, T_CONTENT)
     cid2 = comment.add(T_PROJ_ID, T_REF, T_AUTHOR, T_CONTENT2)
     latest = comment.latest()
     assert latest == [cid1, cid2]
示例#10
0
 def test_get_comment(self):
     cid = comment.add(T_PROJ_ID, T_REF, T_AUTHOR, T_CONTENT)
     com = comment.get(cid)
     assert com[1] == T_PROJ_ID
     assert com[2] == T_REF
示例#11
0
 def test_get_unexisting_comment(self):
     cid = comment.add(T_PROJ_ID, T_REF, T_AUTHOR, T_CONTENT)
     com = comment.get(cid + 1)
     assert com is None
示例#12
0
 def test_chinese_comment(self):
     T_CONTENT_ZH = u'test is 牛B'
     cid = comment.add(T_PROJ_ID, T_REF, T_AUTHOR, T_CONTENT_ZH)
     com = comment.get(cid)
     assert com[4] == T_CONTENT_ZH
示例#13
0
 def test_get_comment(self):
     cid = comment.add(T_PROJ_ID, T_REF, T_AUTHOR, T_CONTENT)
     com = comment.get(cid)
     assert com[1] == T_PROJ_ID
     assert com[2] == T_REF
示例#14
0
 def test_add_comment(self):
     cid1 = comment.add(T_PROJ_ID, T_REF, T_AUTHOR, T_CONTENT)
     assert cid1
     cid2 = comment.add(T_PROJ_ID, T_REF, T_AUTHOR, T_CONTENT)
     assert cid2
     assert cid1 != cid2
示例#15
0
 def _add(self, project_id=T_PROJ_ID, ref=T_REF,
          author=T_AUTHOR, content=T_CONTENT):
     return cC.get(comment.add(project_id, ref, author, content))
示例#16
0
 def test_add_comment(self):
     cid1 = comment.add(T_PROJ_ID, T_REF, T_AUTHOR, T_CONTENT)
     assert cid1
     cid2 = comment.add(T_PROJ_ID, T_REF, T_AUTHOR, T_CONTENT)
     assert cid2
     assert cid1 != cid2
示例#17
0
 def test_gets_by_project_id(self):
     cid1 = comment.add(T_PROJ_ID, T_REF, T_AUTHOR, T_CONTENT)
     comment.add(T_PROJ_ID_2, T_REF, T_AUTHOR, T_CONTENT)
     cid2 = comment.add(T_PROJ_ID, T_REF, T_AUTHOR, T_CONTENT2)
     cmnts = comment.gets_by_project(T_PROJ_ID)
     assert cmnts == [cid1, cid2]
示例#18
0
 def test_modify_comment(self):
     cid = comment.add(T_PROJ_ID, T_REF, T_AUTHOR, T_CONTENT)
     comment.update(cid, {'content': 'new content'})
     assert comment.get(cid)[4] == 'new content'
示例#19
0
 def test_chinese_comment(self):
     T_CONTENT_ZH = 'test is 牛B'
     cid = comment.add(T_PROJ_ID, T_REF, T_AUTHOR, T_CONTENT_ZH)
     com = comment.get(cid)
     assert com[4] == T_CONTENT_ZH
示例#20
0
 def test_get_unexisting_comment(self):
     cid = comment.add(T_PROJ_ID, T_REF, T_AUTHOR, T_CONTENT)
     com = comment.get(cid + 1)
     assert com is None
示例#21
0
 def test_gets_by_ref(self):
     cid1 = comment.add(T_PROJ_ID, T_REF, T_AUTHOR, T_CONTENT)
     comment.add(T_PROJ_ID, T_REF_2, T_AUTHOR, T_CONTENT)
     cid2 = comment.add(T_PROJ_ID, T_REF, T_AUTHOR, T_CONTENT2)
     cmnts = comment.gets_by_ref(T_REF)
     assert cmnts == [cid1, cid2]
示例#22
0
 def test_gets_with_order(self):
     all_cmnts = [comment.add(T_PROJ_ID, T_REF, T_AUTHOR, T_CONTENT)
                  for i in range(30)]
     assert len(all_cmnts) == 30
     assert comment.gets_by_ref(
         T_REF, order='desc')[:30] == list(reversed(all_cmnts))
示例#23
0
 def test_modify_comment(self):
     cid = comment.add(T_PROJ_ID, T_REF, T_AUTHOR, T_CONTENT)
     comment.update(cid, {'content': 'new content'})
     assert comment.get(cid)[4] == 'new content'
示例#24
0
 def _add(self,
          project_id=T_PROJ_ID,
          ref=T_REF,
          author=T_AUTHOR,
          content=T_CONTENT):
     return cC.get(comment.add(project_id, ref, author, content))