예제 #1
0
파일: test_media.py 프로젝트: Syfaro/weasyl
def test_replacing_media_links(db, cls, linked_attr, link_attr, media_attr, generator):
    """
    Media links with the same name get replaced by default.
    """
    linked = generator(db)
    item1 = media_item(db, '1200x6566.png')
    item2 = media_item(db, '1x70.gif')
    cls.make_or_replace_link(getattr(linked, linked_attr), 'test', item1)
    cls.make_or_replace_link(getattr(linked, linked_attr), 'test', item2)
    [link] = cls.query.all()
    assert link.link_type == 'test'
    assert getattr(link, link_attr) == getattr(linked, linked_attr)
    assert getattr(link, media_attr) == item2.mediaid
예제 #2
0
def test_replacing_media_links(db, cls, linked_attr, link_attr, media_attr,
                               generator):
    """
    Media links with the same name get replaced by default.
    """
    linked = generator(db)
    item1 = media_item(db, '1200x6566.png')
    item2 = media_item(db, '1x70.gif')
    cls.make_or_replace_link(getattr(linked, linked_attr), 'test', item1)
    cls.make_or_replace_link(getattr(linked, linked_attr), 'test', item2)
    [link] = cls.query.all()
    assert link.link_type == 'test'
    assert getattr(link, link_attr) == getattr(linked, linked_attr)
    assert getattr(link, media_attr) == item2.mediaid
예제 #3
0
파일: test_media.py 프로젝트: Syfaro/weasyl
def test_multiple_media_links(db, cls, linked_attr, link_attr, media_attr, generator):
    """
    Multiple media links from a single object are possible as long as each link
    has a different name.
    """
    linked = generator(db)
    item1 = media_item(db, '1200x6566.png')
    item2 = media_item(db, '1x70.gif')
    cls.make_or_replace_link(getattr(linked, linked_attr), 'test1', item1)
    cls.make_or_replace_link(getattr(linked, linked_attr), 'test2', item2)
    [link1, link2] = cls.query.order_by(getattr(cls, media_attr).asc()).all()
    assert link1.link_type == 'test1'
    assert getattr(link1, link_attr) == getattr(linked, linked_attr)
    assert getattr(link1, media_attr) == item1.mediaid
    assert link2.link_type == 'test2'
    assert getattr(link2, link_attr) == getattr(linked, linked_attr)
    assert getattr(link2, media_attr) == item2.mediaid
예제 #4
0
def test_multiple_media_links(db, cls, linked_attr, link_attr, media_attr,
                              generator):
    """
    Multiple media links from a single object are possible as long as each link
    has a different name.
    """
    linked = generator(db)
    item1 = media_item(db, '1200x6566.png')
    item2 = media_item(db, '1x70.gif')
    cls.make_or_replace_link(getattr(linked, linked_attr), 'test1', item1)
    cls.make_or_replace_link(getattr(linked, linked_attr), 'test2', item2)
    [link1, link2] = cls.query.order_by(getattr(cls, media_attr).asc()).all()
    assert link1.link_type == 'test1'
    assert getattr(link1, link_attr) == getattr(linked, linked_attr)
    assert getattr(link1, media_attr) == item1.mediaid
    assert link2.link_type == 'test2'
    assert getattr(link2, link_attr) == getattr(linked, linked_attr)
    assert getattr(link2, media_attr) == item2.mediaid
예제 #5
0
파일: test_media.py 프로젝트: Syfaro/weasyl
def test_clearing_media_links(db, cls, linked_attr, link_attr, media_attr, generator):
    """
    A media link can also be cleared.
    """
    linked = generator(db)
    item = media_item(db, '1200x6566.png')
    cls.make_or_replace_link(getattr(linked, linked_attr), 'test', item)
    cls.clear_link(getattr(linked, linked_attr), 'test')
    assert cls.query.count() == 0
예제 #6
0
def test_clearing_media_links(db, cls, linked_attr, link_attr, media_attr,
                              generator):
    """
    A media link can also be cleared.
    """
    linked = generator(db)
    item = media_item(db, '1200x6566.png')
    cls.make_or_replace_link(getattr(linked, linked_attr), 'test', item)
    cls.clear_link(getattr(linked, linked_attr), 'test')
    assert cls.query.count() == 0
예제 #7
0
def test_self_media_links(db):
    """
    Media items can be linked to themselves.
    """
    item = media_item(db, '1200x6566.png')
    media.MediaMediaLink.make_or_replace_link(item.mediaid, 'test', item)
    [link] = media.MediaMediaLink.query.all()
    assert link.link_type == 'test'
    assert link.described_with_id == item.mediaid
    assert link.describee_id == item.mediaid
    assert link.media_item is link.describee
예제 #8
0
파일: test_media.py 프로젝트: Syfaro/weasyl
def test_self_media_links(db):
    """
    Media items can be linked to themselves.
    """
    item = media_item(db, '1200x6566.png')
    media.MediaMediaLink.make_or_replace_link(item.mediaid, 'test', item)
    [link] = media.MediaMediaLink.query.all()
    assert link.link_type == 'test'
    assert link.described_with_id == item.mediaid
    assert link.describee_id == item.mediaid
    assert link.media_item is link.describee
예제 #9
0
파일: test_media.py 프로젝트: Syfaro/weasyl
def test_creating_media_links(db, cls, linked_attr, link_attr, media_attr, generator):
    """
    Media links can be created from different types of objects to media items.
    """
    linked = generator(db)
    item = media_item(db, '1200x6566.png')
    cls.make_or_replace_link(getattr(linked, linked_attr), 'test', item)
    [link] = cls.query.all()
    assert link.link_type == 'test'
    assert getattr(link, link_attr) == getattr(linked, linked_attr)
    assert getattr(link, media_attr) == item.mediaid
예제 #10
0
def test_creating_media_links(db, cls, linked_attr, link_attr, media_attr,
                              generator):
    """
    Media links can be created from different types of objects to media items.
    """
    linked = generator(db)
    item = media_item(db, '1200x6566.png')
    cls.make_or_replace_link(getattr(linked, linked_attr), 'test', item)
    [link] = cls.query.all()
    assert link.link_type == 'test'
    assert getattr(link, link_attr) == getattr(linked, linked_attr)
    assert getattr(link, media_attr) == item.mediaid