def test_SashaConfiguration_get_fixtures_01(self):

        event_fixtures = sasha_configuration.get_fixtures(
            modeltools.Event)
        instrument_fixtures = sasha_configuration.get_fixtures(
            modeltools.Instrument)
        performer_fixtures = sasha_configuration.get_fixtures(
            modeltools.Performer)

        assert len(event_fixtures) == 12
        assert len(instrument_fixtures) == 4
        assert len(performer_fixtures) == 1
Beispiel #2
0
    def test_Bootstrap_instruments_01(self):

        bootstrap = systemtools.Bootstrap()
        fixtures = sasha_configuration.get_fixtures(modeltools.Instrument)
        assert fixtures
        fixtures = bootstrap._sort_instrument_fixtures(fixtures)
        assert fixtures
        mapping = bootstrap._collect_instrument_parents(fixtures)
        assert mapping == {
            u'Aerophone': [],
            u'Saxophone': [u'Aerophone'],
            u'Alto Saxophone': [u'Saxophone', u'Aerophone'],
            u'Soprano Saxophone': [u'Saxophone', u'Aerophone'],
            }
Beispiel #3
0
    def test_Bootstrap_populate_mongodb_primary_01(self):

        bootstrap = systemtools.Bootstrap()
        bootstrap.delete_mongodb_database()

        event_count = modeltools.Event.objects.count()
        instrument_count = modeltools.Instrument.objects.count()
        performer_count = modeltools.Performer.objects.count()

        assert 0 == event_count
        assert 0 == instrument_count
        assert 0 == performer_count

        bootstrap.create_mongodb_database()
        bootstrap.populate_mongodb_primary()

        event_count = modeltools.Event.objects.count()
        instrument_count = modeltools.Instrument.objects.count()
        performer_count = modeltools.Performer.objects.count()

        assert 0 < event_count
        assert 0 < instrument_count
        assert 0 < performer_count

        event_fixtures = sasha_configuration.get_fixtures(
            modeltools.Event)
        instrument_fixtures = sasha_configuration.get_fixtures(
            modeltools.Instrument)
        performer_fixtures = sasha_configuration.get_fixtures(
            modeltools.Performer)

        assert len(event_fixtures) == event_count
        assert len(instrument_fixtures) == instrument_count
        assert len(performer_fixtures) == performer_count

        bootstrap.rebuild_mongodb_database()
Beispiel #4
0
 def populate_mongodb_primary():
     from sasha import sasha_configuration
     from sasha.tools import assettools
     from sasha.tools import modeltools
     # Populate performers.
     performer_fixtures = sasha_configuration.get_fixtures(
         modeltools.Performer)
     performers = []
     for fixture in performer_fixtures:
         performer = modeltools.Performer(
             name=fixture['name'],
             )
         performers.append(performer)
     assert performers
     modeltools.Performer.objects.insert(performers)
     # Populate instruments.
     instrument_fixtures = sasha_configuration.get_fixtures(
         modeltools.Instrument)
     instrument_fixtures = Bootstrap._sort_instrument_fixtures(
         instrument_fixtures)
     instruments = []
     for fixture in instrument_fixtures:
         instrument = modeltools.Instrument(
             key_names=fixture['key_names'],
             name=fixture['name'],
             transposition=int(fixture['transposition']),
             )
         instruments.append(instrument)
     assert instruments
     modeltools.Instrument.objects.insert(instruments)
     instrument_mapping = Bootstrap._collect_instrument_parents(
         instrument_fixtures)
     for child_name, parent_names in instrument_mapping.items():
         if not parent_names:
             continue
         child = modeltools.Instrument.objects(name=child_name).first()
         parents = []
         for parent_name in parent_names:
             parent = modeltools.Instrument.objects(
                 name=parent_name).first()
             parents.append(parent)
         child.parents = parents
         child.save()
     # Populate events.
     event_fixtures = sasha_configuration.get_fixtures(
         modeltools.Event)
     events = []
     for fixture in event_fixtures:
         instrument = modeltools.Instrument.objects(
             name=fixture['instrument'],
             ).first()
         performer = modeltools.Performer.objects(
             name=fixture['performer'],
             ).first()
         fingering = modeltools.Fingering(
             instrument=instrument,
             key_names=fixture['fingering'],
             )
         fingering.compact_representation = \
             modeltools.Fingering.get_compact_representation(
                 fingering.key_names,
                 instrument.key_names,
                 )
         event = modeltools.Event(
             fingering=fingering,
             name=fixture['name'],
             performer=performer,
             )
         event.md5 = assettools.SourceAudio(event).md5
         events.append(event)
     assert events
     modeltools.Event.objects.insert(events)