forked from DGNum/gestioCOF
Tests pour la suppression d'articles
This commit is contained in:
parent
65dd7e5fa3
commit
d4be8b426e
1 changed files with 36 additions and 0 deletions
|
@ -1345,6 +1345,42 @@ class ArticleUpdateViewTests(ViewTestCaseMixin, TestCase):
|
|||
self.assertForbiddenKfet(r)
|
||||
|
||||
|
||||
class ArticleDeleteViewTests(ViewTestCaseMixin, TestCase):
|
||||
url_name = "kfet.article.delete"
|
||||
|
||||
auth_user = "team1"
|
||||
auth_forbidden = [None, "user", "team"]
|
||||
|
||||
@property
|
||||
def url_kwargs(self):
|
||||
return {"pk": self.article.pk}
|
||||
|
||||
@property
|
||||
def url_expected(self):
|
||||
return "/k-fet/articles/{}/delete".format(self.article.pk)
|
||||
|
||||
def get_users_extra(self):
|
||||
return {"team1": create_team("team1", "101", perms=["kfet.delete_article"])}
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.category = ArticleCategory.objects.create(name="Category")
|
||||
self.article = Article.objects.create(
|
||||
name="Article", category=self.category, stock=5, price=Decimal("2.5")
|
||||
)
|
||||
|
||||
def test_get_redirects(self):
|
||||
r = self.client.get(self.url)
|
||||
self.assertRedirects(r, reverse("kfet.article.read", kwargs=self.url_kwargs))
|
||||
|
||||
def test_post_ok(self):
|
||||
r = self.client.post(self.url, {})
|
||||
self.assertRedirects(r, reverse("kfet.article"))
|
||||
|
||||
with self.assertRaises(Article.DoesNotExist):
|
||||
self.article.refresh_from_db()
|
||||
|
||||
|
||||
class ArticleStatSalesListViewTests(ViewTestCaseMixin, TestCase):
|
||||
url_name = "kfet.article.stat.sales.list"
|
||||
|
||||
|
|
Loading…
Reference in a new issue