示例#1
0
文件: test_api.py 项目: Ferdi/lore
    def test_get_vocabulary(self):
        """
        Test get_vocabulary
        """

        actual_vocabulary = get_vocabulary(self.vocabulary.id)
        self.assertEquals(self.vocabulary, actual_vocabulary)

        self.assertRaises(Http404,
                          lambda: get_vocabulary(3))
        self.assertRaises(Http404,
                          lambda: get_vocabulary(None))
示例#2
0
文件: permissions.py 项目: olabi/lore
 def has_permission(self, request, view):
     try:
         get_vocabulary(
             view.kwargs['repo_slug'],
             request.user.id,
             view.kwargs['vocab_slug']
         )
     except NotFound:
         raise Http404()
     except PermissionDenied:
         return False
     return True
示例#3
0
    def test_get_vocabulary(self):
        """
        Test get_vocabulary
        """

        actual_vocabulary = get_vocabulary(self.repo.slug, self.user.id,
                                           self.vocabulary.slug)
        self.assertEqual(self.vocabulary, actual_vocabulary)

        with self.assertRaises(NotFound):
            get_vocabulary("missing", self.user.id, self.vocabulary.slug)
        with self.assertRaises(PermissionDenied):
            get_vocabulary(self.repo.slug, -1, self.vocabulary.slug)
        with self.assertRaises(NotFound):
            get_vocabulary(self.repo.slug, self.user.id, "missing")
示例#4
0
    def test_get_vocabulary(self):
        """
        Test get_vocabulary
        """

        actual_vocabulary = get_vocabulary(
            self.repo.slug, self.user.id, self.vocabulary.slug)
        self.assertEquals(self.vocabulary, actual_vocabulary)

        with self.assertRaises(NotFound):
            get_vocabulary("missing", self.user.id, self.vocabulary.slug)
        with self.assertRaises(PermissionDenied):
            get_vocabulary(self.repo.slug, -1, self.vocabulary.slug)
        with self.assertRaises(NotFound):
            get_vocabulary(self.repo.slug, self.user.id, "missing")