コード例 #1
0
ファイル: history.py プロジェクト: azime/Chaos-1
def create_associate_disruption_property_from_json(json, disruption_id, value):
    adp = models.AssociateDisruptionProperty()
    adp.disruption_id = disruption_id
    adp.property_id = json['id']
    adp.value = value
    adp.property = create_property_from_json(json)

    return adp
コード例 #2
0
ファイル: fields_test.py プロジェクト: kinnou02/Chaos-1
def test_name_associate_disruption_property():
    adp = models.AssociateDisruptionProperty()
    adp.value = 'value'
    adp.property_id = 'property_id'
    adp.disruption_id = 'disruption_id'
    eq_(
        str(adp), "<AssociateDisruptionProperty: {} {} {}>".format(
            adp.property_id, adp.disruption_id, adp.value))
コード例 #3
0
def create_adp(disruption, property_id, value):
    """ Create or update an associate_disruption_property object in database
    """
    adp = models.AssociateDisruptionProperty.get(property_id, disruption.id,
                                                 value)

    if adp is None:
        adp = models.AssociateDisruptionProperty()
        adp.value = value
        adp.disruption_id = disruption.id
        adp.property_id = property_id
        db.session.add(adp)

    return adp