Skip to content

Commit

Permalink
#887 Test if all category.get_siblings are active
Browse files Browse the repository at this point in the history
  • Loading branch information
duker33 committed Jun 21, 2019
1 parent 997c7a0 commit 0039750
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion shopelectro/tests/tests_models.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,38 @@
from functools import partial
from itertools import chain

from django.conf import settings
from django.forms.models import model_to_dict
from django.test import TestCase, TransactionTestCase, tag
from itertools import chain

from pages import models as pages_models
from shopelectro import models as se_models
from shopelectro.models import Product, Tag, TagGroup


@tag('fast')
class Category(TestCase):

fixtures = ['dump.json']

def test_siblings_is_active(self):
category = se_models.Category.objects.raw(
'SELECT * FROM shopelectro_category AS P'
' WHERE P.id = ('
' SELECT C.parent_id FROM shopelectro_category as C'
' GROUP BY C.parent_id'
' HAVING COUNT(C.parent_id) > 1'
' LIMIT 1'
' )'
)[0]
(
pages_models.Page.objects
.filter(id=category.children.first().page.id)
.update(is_active=False)
)
self.assertTrue(all((c.page.is_active for c in category.get_siblings())))


@tag('fast')
class ProductModel(TestCase):

Expand Down

0 comments on commit 0039750

Please sign in to comment.