コード例 #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")