Skip to content

Commit

Permalink
ALB002 account for None
Browse files Browse the repository at this point in the history
  • Loading branch information
aothms committed Jan 27, 2023
1 parent a488fe3 commit 45690e3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion features/steps/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,17 +723,20 @@ def step_impl(context, entity, other_entity, relationship):
errors.append(instance_placement_error(entity, '', container, relationship, container_obj_placement,
entity_obj_placement_rel))
handle_errors(context, errors)


@then ('The type of attribute {attribute} should be {expected_entity_type}')
def step_impl(context, attribute, expected_entity_type):

def _():
for inst in context.instances:
related_entity = getattr(inst, attribute, [])
if not related_entity.is_a(expected_entity_type):
if not related_entity or not related_entity.is_a(expected_entity_type):
yield attribute_type_error(inst, [related_entity], attribute, expected_entity_type)

handle_errors(context, list(_()))


@given('The {representation_id} shape representation has RepresentationType "{representation_type}"')
def step_impl(context, representation_id, representation_type):
context.instances =list(filter(None, list(map(lambda i: instance_getter(i, representation_id, representation_type), context.instances))))
Expand Down

0 comments on commit 45690e3

Please sign in to comment.