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))
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
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")
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")