rcxwhiz / django-hierarchical-models

MIT License
1 stars 0 forks source link

Create interface testing system #2

Closed rcxwhiz closed 4 months ago

rcxwhiz commented 4 months ago

Because each of the models should be implementing the same HierarchicalModel interface, I should be able to make some sort of TestCase mixin thing, like this

from django.test import TestCase

class AdjacencyListModelTests(HierarchicalModelTests[AdjacencyListModel], TestCase):
    pass

Although due to migrations I might possibly need to replace [AdjacencyListModel] with [SomeAdjacencyListModelSubclass].

rcxwhiz commented 4 months ago

I've got a drawing of 32 nodes and how I would like to assemble them for testing. I'll use these to add some extended tests to the test suite.

rcxwhiz commented 4 months ago

I'm realizing that for these tests to be deterministic, there will need to be a parameter added to the children method (and the direct_children method) so that the order the children get chosen in can be set.

rcxwhiz commented 4 months ago

At that point it might be worth it to pass in a lambda parameter so you can transform the queryset to your liking? Not just with a call to order_by.

rcxwhiz commented 4 months ago

I should also probably take off the name fields from the test model and just put in an integer field so I can identify the models. That reminds me that I also might have to define __eq__ on HierarchicalModel.Node so that I can assert that trees of children are equal.

rcxwhiz commented 4 months ago

Got the argument added to the get children stuff so that you can specify the order that you get children in.

rcxwhiz commented 4 months ago

Got the test model switch to an integer field instead of name fields.