예제 #1
0
 def test_get_repositories_existed_keyword(self):
     """
     测试 有效关键字下的 catalog 搜索返回
     :return:
     """
     keyword = "m"
     self.assertFalse(self.repo_name.find(keyword) > 0)
     self.assertEqual([], storage.get_repositories(keyword=keyword))
예제 #2
0
 def test_get_repositories(self):
     """
     测试 catalog 查询
     :return:
     """
     dir_name = settings.REPO_DIR + "/%s/_layers" % self.repo_name
     if not os.path.exists(dir_name):
         os.makedirs(dir_name)
     self.assertEqual([self.repo_name], storage.get_repositories())
예제 #3
0
 def get(self, request):
     """
     catalog view
     :param request: Http 请求对象
     :return:
     """
     q = request.GET.get("q", request.data.get("q", ""))
     n = request.GET.get("n", request.data.get("n", 10))
     try:
         n = int(n)
     except ValueError:
         n = 10
     repositories = storage.get_repositories(keyword=q, n=n)
     return http.JsonResponse(data={"repositories": repositories})
예제 #4
0
 def test_get_repositories_empty(self):
     """
     测试没有测试数据下的catalog 返回
     :return:
     """
     self.assertEqual([], storage.get_repositories())  # 没有测试数据应该为空