def test_zone_add_maxlength(request, soft_assert):
    zc = current_appliance.get(ZoneCollection)
    zone = zc.create(name=fauxfactory.gen_alphanumeric(50),
                     description=fauxfactory.gen_alphanumeric(50))
    request.addfinalizer(zone.delete)
    soft_assert(zone.exists,
                "The zone {} does not exist!".format(zone.description))
def test_zone_add_dupe(request):
    zc = current_appliance.get(ZoneCollection)
    name = fauxfactory.gen_alphanumeric(5)
    description = fauxfactory.gen_alphanumeric(8)
    zone = zc.create(name=name, description=description)
    request.addfinalizer(zone.delete)

    with error.expected('Name has already been taken'):
        zc.create(name=name, description=description)
def test_zone_crud(soft_assert):
    zc = current_appliance.get(ZoneCollection)
    # CREATE
    zone = zc.create(name=fauxfactory.gen_alphanumeric(5),
                     description=fauxfactory.gen_alphanumeric(8))
    soft_assert(zone.exists,
                "The zone {} does not exist!".format(zone.description))
    # UPDATE
    old_desc = zone.description
    with update(zone):
        zone.description = fauxfactory.gen_alphanumeric(8)
    soft_assert(zone.exists and (old_desc != zone.description),
                "The zone {} was not updated!".format(zone.description))
    # DELETE
    zone.delete()
    soft_assert(not zone.exists,
                "The zone {} exists!".format(zone.description))
def test_zone_add_cancel_validation():
    zc = current_appliance.get(ZoneCollection)
    # CREATE
    zc.create(name=fauxfactory.gen_alphanumeric(5),
              description=fauxfactory.gen_alphanumeric(8),
              cancel=True)