示例#1
0
    def make_some_vocab_tags(cls):
        model.repo.new_revision()

        # Create a couple of vocabularies.
        genre_vocab = model.Vocabulary(u'genre')
        model.Session.add(genre_vocab)
        composers_vocab = model.Vocabulary(u'composers')
        model.Session.add(composers_vocab)

        # Create some additional free tags for tag search tests.
        tolkien_tag = model.Tag(name="tolkien")
        model.Session.add(tolkien_tag)
        toledo_tag = model.Tag(name="toledo")
        model.Session.add(toledo_tag)
        tolerance_tag = model.Tag(name="tolerance")
        model.Session.add(tolerance_tag)
        tollbooth_tag = model.Tag(name="tollbooth")
        model.Session.add(tollbooth_tag)
        # We have to add free tags to a package or they won't show up in tag results.
        model.Package.get('warandpeace').add_tags((tolkien_tag, toledo_tag,
            tolerance_tag, tollbooth_tag))

        # Create some tags that belong to vocabularies.
        sonata_tag = model.Tag(name=u'sonata', vocabulary_id=genre_vocab.id)
        model.Session.add(sonata_tag)

        bach_tag = model.Tag(name=u'Bach', vocabulary_id=composers_vocab.id)
        model.Session.add(bach_tag)

        neoclassical_tag = model.Tag(name='neoclassical',
                vocabulary_id=genre_vocab.id)
        model.Session.add(neoclassical_tag)

        neofolk_tag = model.Tag(name='neofolk', vocabulary_id=genre_vocab.id)
        model.Session.add(neofolk_tag)

        neomedieval_tag = model.Tag(name='neomedieval',
                vocabulary_id=genre_vocab.id)
        model.Session.add(neomedieval_tag)

        neoprog_tag = model.Tag(name='neoprog',
                vocabulary_id=genre_vocab.id)
        model.Session.add(neoprog_tag)

        neopsychedelia_tag = model.Tag(name='neopsychedelia',
                vocabulary_id=genre_vocab.id)
        model.Session.add(neopsychedelia_tag)

        neosoul_tag = model.Tag(name='neosoul', vocabulary_id=genre_vocab.id)
        model.Session.add(neosoul_tag)

        nerdcore_tag = model.Tag(name='nerdcore', vocabulary_id=genre_vocab.id)
        model.Session.add(nerdcore_tag)

        model.Package.get('warandpeace').add_tag(bach_tag)
        model.Package.get('annakarenina').add_tag(sonata_tag)

        model.Session.commit()
示例#2
0
    def setup_class(cls):
        if not tests.is_search_supported():
            raise tests.SkipTest("Search not supported")
        tests.setup_test_search_index()

        ctd.CreateTestData.create()

        model.repo.new_revision()
        cls.vocab = model.Vocabulary(TEST_VOCAB_NAME)
        model.Session.add(cls.vocab)
        model.Session.commit()

        vocab_tag_1 = model.Tag('tag1', cls.vocab.id)
        vocab_tag_2 = model.Tag('tag2', cls.vocab.id)
        model.Session.add(vocab_tag_1)
        model.Session.add(vocab_tag_2)

        pkg = model.Package.get('warandpeace')
        pkg_tag1 = model.PackageTag(pkg, vocab_tag_1)
        pkg_tag2 = model.PackageTag(pkg, vocab_tag_2)
        model.Session.add(pkg_tag1)
        model.Session.add(pkg_tag2)

        model.Session.commit()
        model.Session.remove()
示例#3
0
 def setup_class(cls):
     cls.vocab = model.Vocabulary(TEST_VOCAB_NAME)
     model.Session.add(cls.vocab)
     model.Session.commit()
     vocab_tag_1 = model.Tag('tag1', cls.vocab.id)
     vocab_tag_2 = model.Tag('tag2', cls.vocab.id)
     model.Session.add(vocab_tag_1)
     model.Session.add(vocab_tag_2)
     model.Session.commit()
     model.Session.remove()
示例#4
0
 def initial_data(self, clean_db):
     self.vocab = model.Vocabulary(TEST_VOCAB_NAME)
     model.Session.add(self.vocab)
     model.Session.commit()
     vocab_tag_1 = model.Tag("tag1", self.vocab.id)
     vocab_tag_2 = model.Tag("tag2", self.vocab.id)
     model.Session.add(vocab_tag_1)
     model.Session.add(vocab_tag_2)
     model.Session.commit()
     model.Session.remove()
示例#5
0
def vocabulary_dict_save(vocabulary_dict: dict[str, Any],
                         context: Context) -> 'model.Vocabulary':
    model = context['model']
    session = context['session']
    vocabulary_name = vocabulary_dict['name']

    vocabulary_obj = model.Vocabulary(vocabulary_name)
    session.add(vocabulary_obj)

    if 'tags' in vocabulary_dict:
        vocabulary_tag_list_save(vocabulary_dict['tags'], vocabulary_obj,
                                 context)

    return vocabulary_obj
示例#6
0
    def initial_data(self, clean_db, clean_index):
        if not tests.is_search_supported():
            raise tests.SkipTest("Search not supported")

        ctd.CreateTestData.create()

        self.vocab = model.Vocabulary(TEST_VOCAB_NAME)
        model.Session.add(self.vocab)
        model.Session.commit()

        vocab_tag_1 = model.Tag("tag1", self.vocab.id)
        vocab_tag_2 = model.Tag("tag2", self.vocab.id)
        model.Session.add(vocab_tag_1)
        model.Session.add(vocab_tag_2)

        pkg = model.Package.get("warandpeace")
        pkg_tag1 = model.PackageTag(pkg, vocab_tag_1)
        pkg_tag2 = model.PackageTag(pkg, vocab_tag_2)
        model.Session.add(pkg_tag1)
        model.Session.add(pkg_tag2)

        model.Session.commit()
        model.Session.remove()