Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

admin.py:61-62: Test category filtering at the admin... #998

Open
0pdd opened this issue Oct 10, 2019 · 4 comments
Open

admin.py:61-62: Test category filtering at the admin... #998

0pdd opened this issue Oct 10, 2019 · 4 comments
Assignees
Labels
3 we can defer this issue. But it'll good to implement it 30 mins middle-sized issue. Usually a part of feature or a fix cleanup everything that do project stronger, flexible, reusable

Comments

@0pdd
Copy link
Collaborator

0pdd commented Oct 10, 2019

The puzzle 996-4e0aa46a from #996 has to be resolved:

# @todo #996:30m Test category filtering at the admin page.
# Use standard django test client, without selenium.

The puzzle was created by duker33 on 10-Oct-19.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

@0pdd
Copy link
Collaborator Author

0pdd commented Oct 10, 2019

@artemiyds2 @duker33 please pay attention to this new issue.

0pdd referenced this issue Oct 10, 2019
* #996  Fix categories filter logic

* #996  Instruction how to add categories
@duker33 duker33 added 3 we can defer this issue. But it'll good to implement it 30 mins middle-sized issue. Usually a part of feature or a fix cleanup everything that do project stronger, flexible, reusable labels Oct 10, 2019
@duker33
Copy link
Contributor

duker33 commented Nov 1, 2019

@olegush , you should create new file test_views_admin.py and fetch filtered products list from admin page. Filtered products list is just get-query, you should assemble the query. Or show that it's impossible

@olegush
Copy link
Collaborator

olegush commented Nov 1, 2019

I created new file inside tests/

from django.test import TestCase, tag

from django.contrib import admin
from shopelectro.admin import HasCategoryFilter
from shopelectro.models import Product


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

    fixtures = ['dump.json']

    def test_category_filtering(self):
        products_db_categorized = Product.objects.filter(category__isnull=False)
        products_db_nocategorized = Product.objects.filter(category__isnull=True)
        # products_admin_categorized = ?
        # products_admin_nocategorized = ?
        self.assertEqual(products_db_categorized, products_admin_categorized)
        self.assertEqual(products_db_nocategorized, products_admin_nocategorized)

But did not understand how to get products from admin yet. I'll try later with get-query.

@duker33
Copy link
Contributor

duker33 commented Nov 4, 2019

get-query

i mean HTTP GET method of course.

It's example of filtered page url on the admin side:
https://www.shopelectro.ru/admin/shopelectro/categorypage/?has_content=yes&has_images=no&is_active__exact=1

You should construct the same url in your test code ahead. Code looks in right direction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 we can defer this issue. But it'll good to implement it 30 mins middle-sized issue. Usually a part of feature or a fix cleanup everything that do project stronger, flexible, reusable
Projects
None yet
Development

No branches or pull requests

3 participants