Skip to content

Conversation

@smcoll
Copy link
Contributor

@smcoll smcoll commented Apr 29, 2015

i'm making this PR to get some feedback. What i did so far is essentially plagiarize some of the django_polymorphic test suite. My plan is to eventually add in mptt-related tests as well.

i'd like some input on what types of tests are going to be really necessary. So far, for example, i'm basically duplicating test cases from django_polymorphic so far. (You'll notice that one of them fails, which i believe may be evidence that django-polymorphic-tree diverges in that case). i presume at least some of the polymorphic tests aren't going to be necessary; perhaps some of their regression tests.

At the moment, i'm leveraging ShowFieldType from the polymorphic app, which seems helpful, but all the mptt fields (as well as how the field ordering works out) is pretty verbose. Also, i don't know the advisability of dependencies on other test suites, although strictly speaking, ShowFieldType isn't in django_polymorphic's tests module.

i'm planning to add additonal files in the tests module like test_admin.py, etc.

Is there an alternate approach to porting the polymorphic and mptt tests into our app?

@vdboor
Copy link
Member

vdboor commented Apr 30, 2015

Great work, thanks! I'm really happy you're starting work on a testsuite, this has been one of my itches too.

I'm not so sure about duplicating all polymorphic tests, but verifying some makes sense for sure! (given we place a custom manager on the models).

At the moment, i'm leveraging ShowFieldType from the polymorphic app, which seems helpful, but all the mptt fields (as well as how the field ordering works out) is pretty verbose.

Agreed. This class bothers some a bit in polymorphic, because it seems more like a testing tool then anything else. Feel free to make a copy of that class in this package, to have it in polymorphic_tree.tests.utils or something.

@vdboor
Copy link
Member

vdboor commented Apr 30, 2015

For inspiration on things to test, you may find the "closed issues" useful.

Some that come into mind are #37, and #32

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test fails. The base manager is polymorphic_tree.managers.PolymorphicMPTTModelManager. What is the desired behavior? django-polymorphic returns django.db.models.manager.Manager as the base manager of a subclass of PolymorphicModel. Perhaps we should be offering mptt.managers.TreeManager as the base manager for subclasses?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure here. TreeManager maybe if you following the "manager - polymorphic" rule, maybe PolymorphicMPTTModelManager because the functionality needs to be there.

I guess it depends on the effect that _base_manager has.

@smcoll
Copy link
Contributor Author

smcoll commented Apr 30, 2015

@vdboor Alright, i added more tests, including for #32 and #37 (the latter of which has failing tests) and got the tests running in all supported Django versions. i'm open to suggestions regarding the organization and content of the tests in test_models.py particularly.

@smcoll
Copy link
Contributor Author

smcoll commented May 4, 2015

@vdboor what would you like to see in this PR before you'd be willing to accept it?

@vdboor vdboor merged commit 8d5abcc into django-polymorphic:master Dec 29, 2015
@vdboor
Copy link
Member

vdboor commented Dec 29, 2015

Nothing after further inspection :) I've made some adjustments - finally took the time to look into it, and fix the sibling tests too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants