Example #1
0
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
Example #2
0
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))
Example #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