jkoelker / quark

This is my fork, Quark is now at https://github.com/rackerlabs/quark
Apache License 2.0
0 stars 2 forks source link

Registering a UUID generator in the plugin init is making testing kind of hairy #130

Closed MattDietz closed 11 years ago

MattDietz commented 11 years ago

Specifically, the block:

    # NOTE(jkoelker) Register the event on all models that have ids
    for _name, klass in inspect.getmembers(models, inspect.isclass):
        if klass is models.HasId:
            continue

        if models.HasId in klass.mro():
            event.listen(klass, "init", _perhaps_generate_id)

This causes issues because of a subtle interdependency. Reorganizing the plugin into separate submodules revealed this because the test ordering changed, causing the plugin to not be the first one to configure the database, which in turn means the event listener on all models with HasId set weren't generating UUIDs in some cases. From the looks of things, someone previously noticed this and set an assertIsNone on the entity UUID on some of the IPAM test cases instead of trying to figure out why it would assign an ID in some cases and not others :-1: