moo.core.tests.test_multi_universe

Tests for multi-universe support via Django Sites.

Covers the full PR-description test plan plus regressions for the avatar-hijack hole and the migration backfill step.

Functions

test_avatar_hijack_resistance(t_two_sites)

A non-unique object with the same name+site cannot be hijacked as a wizard avatar.

test_lookup_dollar_returns_active_site_system(...)

lookup("$player") resolves through the active site's System Object.

test_lookup_int_pk_cross_site_raises(...)

Integer-PK lookup is site-scoped: a PK from site1 is invisible from site2.

test_migration_0030_backfills_existing_rows(t_init)

Reproduce the migration RunPython step: rows with site=NULL get SITE_ID.

test_moo_init_hostname_creates_site()

moo_init --hostname=foo.com creates the Site and bootstraps it.

test_moojson_cross_site_ref_decodes_as_nothing(...)

A property value referring to another site's PK decodes as $nothing.

test_moojson_decode_without_site_context_preserves_object(...)

Deserializing an Object ref outside any site context returns the original object, not $nothing.

test_non_universal_superuser_does_not_auto_provision(...)

A Django superuser without a UniversalWizard record gets nothing on connect.

test_object_save_fills_site(source, ...)

Object.save() fills site in priority order: context > caller > default SITE_ID.

test_resolve_site_no_suffix_defers_to_picker(...)

No suffix means defer to picker — site stays None.

test_resolve_site_unknown_suffix_defers_to_picker(...)

An unknown suffix leaves site=None so interact() shows the picker.

test_resolve_site_via_username_suffix(...)

A username suffix matching a Site domain selects that Site.

test_single_site_unchanged(t_init, t_wizard)

Default SITE_ID=1 flow: lookup, save, and create all behave as before.

test_site_manager_fails_closed_when_site_missing(t_init)

If _current_site() returns None at runtime, SiteManager returns no rows.

test_site_manager_filters_queryset(t_two_sites)

Object.objects returns only the active site; global_objects returns everything.

test_split_user_suffix_basic()

user+sitedomain parses into base username + suffix.

test_two_sites_isolated(t_two_sites)

Each site has its own System Object, Wizard, and hierarchy.

test_universal_wizard_auto_provisions_idempotently(...)

A UniversalWizard user gets a wizard avatar+Player on first connect; a second call is a no-op.