示例#1
0
def test_new_items_have_current_tags(qApp):

    s = Document()
    s.setTags(['are', 'here', 'you'])
    layer1 = Layer(tags=['here'])
    s.addItem(layer1)
    p1 = Person(name='p1')
    assert p1.tags() == []

    layer1.setActive(True)
    assert p1.tags() == []

    p2 = Person(name='p2')
    s.addItem(p2)
    assert p1.tags() == []
    assert p2.tags() == ['here']
    
    layer2 = Layer(tags=['you'], active=True)
    s.addItem(layer2)
    assert p1.tags() == []
    assert p2.tags() == ['here']
     
    p3 = Person(name='p3')
    s.addItem(p3)
    assert p1.tags() == []
    assert p2.tags() == ['here']
    assert p3.tags() == ['here', 'you']

    layer1.setActive(False)
    p4 = Person(name='p4')
    s.addItem(p4)
    assert p1.tags() == []
    assert p2.tags() == ['here']
    assert p3.tags() == ['here', 'you']
    assert p4.tags() == ['you']
示例#2
0
def test_update_set_tag_on_inspected_items_out_of_layer(qApp):
    """ Show layer with people that have emotional process
    symbols that don’t have the layer’s tags, inspect those
    symbols from personal timeline, add tag for the layer -> symbols don’t appear.
    """
    tags = ['here']
    s = Document()
    s.setTags(tags)
    layer1 = Layer(tags=tags)
    s.addItem(layer1)
    p1 = Person(name='p1', tags=tags)
    p2 = Person(name='p2', tags=tags)
    s.addItems(p1, p2)
    cutoff = Emotion(kind=util.ITEM_CUTOFF, personA=p1, personB=p2)
    s.addItems(cutoff)
    layer1.setActive(True)
    date = QDate.currentDate()
    assert p1.shouldShowFor(date, tags) == True
    assert p2.shouldShowFor(date, tags) == True
    assert cutoff.shouldShowFor(date, tags) == False
    assert cutoff.isVisible() == False

    # Simulate inspecting a hidden emotion from person props
    cutoff.setTags(tags)
    assert cutoff.shouldShowFor(date, tags) == True
    assert cutoff.isVisible() == True
示例#3
0
def test_hasActiveLayers(qApp):
    document = Document()
    assert document.hasActiveLayers == False
    
    layer = Layer(active=True)
    document.addItem(layer)
    assert document.hasActiveLayers == True

    layer.setActive(False)
    assert document.hasActiveLayers == False
示例#4
0
def test_hasActiveLayers(qApp):
    document = Document()
    model = DocumentModel()
    model.document = document
    assert model.hasActiveLayers == document.hasActiveLayers

    layer = Layer(active=True)
    document.addItem(layer)
    assert model.hasActiveLayers == document.hasActiveLayers

    layer.setActive(False)
    assert model.hasActiveLayers == document.hasActiveLayers
示例#5
0
def test_layered_property(qApp):

    document = Document()
    item = LayeredItem()
    layer = Layer(name='Layer 1')
    document.addItem(item)
    document.addItem(layer)

    assert item.num() == -1
    assert item.count == 0
    assert item.layeredCount == 0

    item.setNum(1)
    assert item.num() == 1
    assert item.count == 1
    assert item.layeredCount == 0

    layer.setActive(True)
    assert item.num() == 1
    assert item.count == 1
    assert item.layeredCount == 0

    item.prop('num').set(2)
    # item.setNum(2)
    assert item.num() == 2
    assert item.count == 2
    assert item.layeredCount == 1

    layer.setActive(False)
    assert item.num() == 1
    assert item.count == 3
    assert item.layeredCount == 1

    layer.setActive(True)
    assert item.num() == 2
    assert item.count == 4
    assert item.layeredCount == 2

    item.prop('num').reset()
    assert item.num() == 1
    assert item.count == 5
    assert item.layeredCount == 2

    layer.setActive(False)
    assert item.num() == 1
    assert item.count == 5
    assert item.layeredCount == 2
示例#6
0
def test_layered_properties(qApp):
    """ Ensure correct layered prop updates for marriage+marriage-indicators. """
    document = Document()
    male = Person(name='Male', kind='male')
    female = Person(name='Female', kind='female')
    marriage = Marriage(personA=male, personB=female)
    divorcedEvent = Event(parent=marriage, uniqueId='divorced', date=QDate(1900, 1, 1))
    layer = Layer(name='Layer 1')
    document.addItems(male, female, marriage, layer)
    #
    unlayered = {
        'male': QPointF(-100, -50),
        'maleDetails': QPointF(100, 100),
        'female': QPointF(100, -50),
        'femaleDetails': QPointF(-100,-200),
        'marriageSep': QPointF(100, 0),
        'marriageDetails': QPointF(-25, 0),
    }
    layered = {
        'male': QPointF(-200, -150),
        'maleDetails': QPointF(-100, -100),
        'female': QPointF(100, 50),
        'femaleDetails': QPointF(100, 200),
        'marriageSep': QPointF(100, 0),
        'marriageDetails': QPointF(25, -100),
    }
    # layered
    layer.setItemProperty(male.id, 'itemPos', layered['male'])
    layer.setItemProperty(male.detailsText.id, 'itemPos', layered['maleDetails'])
    layer.setItemProperty(female.id, 'itemPos', layered['female'])
    layer.setItemProperty(female.detailsText.id, 'itemPos', layered['femaleDetails'])
    layer.setItemProperty(marriage.detailsText.id, 'itemPos', layered['marriageDetails'])
    layer.setItemProperty(marriage.separationIndicator.id, 'itemPos', layered['marriageSep'])
    # unlayered
    male.setItemPos(unlayered['male'], undo=False)
    male.detailsText.setItemPos(unlayered['maleDetails'], undo=False)
    female.setItemPos(unlayered['female'], undo=False)
    female.detailsText.setItemPos(unlayered['femaleDetails'], undo=False)
    # marriage.setDivorced(True, undo=False)
    marriage.separationIndicator.setItemPos(unlayered['marriageSep'], undo=False)
    marriage.detailsText.setItemPos(unlayered['marriageDetails'], undo=False)
    
    assert male.pos() == unlayered['male']
    assert male.detailsText.pos() == unlayered['maleDetails']
    assert female.pos() == unlayered['female']
    assert female.detailsText.pos() == unlayered['femaleDetails']
    assert marriage.detailsText.pos() == unlayered['marriageDetails']
    assert marriage.separationIndicator.pos() == unlayered['marriageSep']

    layer.setActive(True)
    assert male.pos() == layered['male']
    assert male.detailsText.pos() == layered['maleDetails']
    assert female.pos() == layered['female']
    assert female.detailsText.pos() == layered['femaleDetails']
    assert marriage.detailsText.pos() == layered['marriageDetails']
    assert marriage.separationIndicator.pos() == layered['marriageSep']
    
    layer.setActive(False)
    assert male.pos() == unlayered['male']
    assert male.detailsText.pos() == unlayered['maleDetails']
    assert female.pos() == unlayered['female']
    assert female.detailsText.pos() == unlayered['femaleDetails']
    assert marriage.detailsText.pos() == unlayered['marriageDetails']
    assert marriage.separationIndicator.pos() == unlayered['marriageSep']
 
    layer.resetItemProperty(male.prop('itemPos'))
    layer.resetItemProperty(male.detailsText.prop('itemPos'))
    layer.resetItemProperty(female.prop('itemPos'))
    layer.resetItemProperty(female.detailsText.prop('itemPos'))
    layer.resetItemProperty(marriage.detailsText.prop('itemPos'))
    layer.resetItemProperty(marriage.separationIndicator.prop('itemPos'))
    layer.setActive(True)
    assert male.pos() == unlayered['male']
    assert male.detailsText.pos() == unlayered['maleDetails']
    assert female.pos() == unlayered['female']
    assert female.detailsText.pos() == unlayered['femaleDetails']
    assert marriage.detailsText.pos() == unlayered['marriageDetails']
    assert marriage.separationIndicator.pos() == unlayered['marriageSep']