def test_can_build_resource_with_single_dep(self): role = models.PreCreatedIAMRole(role_arn='foo') app = models.Application(stage='dev', resources=[role]) dep_builder = DependencyBuilder() deps = dep_builder.build_dependencies(app) assert deps == [role]
def test_no_duplicate_depedencies(self): leaf = LeafResource(name='leaf') second_parent = FooResource(name='second', leaf=leaf) first_parent = FooResource(name='first', leaf=[leaf, second_parent]) app = models.Application(stage='dev', resources=[first_parent]) dep_builder = DependencyBuilder() deps = dep_builder.build_dependencies(app) assert deps == [leaf, second_parent, first_parent]
def test_is_first_element_in_list(self): shared_leaf = LeafResource(name='leaf-resource') first_parent = FooResource(name='first', leaf=shared_leaf) app = models.Application( stage='dev', resources=[first_parent, shared_leaf], ) dep_builder = DependencyBuilder() deps = dep_builder.build_dependencies(app) assert deps == [shared_leaf, first_parent]
def test_can_build_resource_with_dag_deps(self): shared_leaf = LeafResource(name='leaf-resource') first_parent = FooResource(name='first', leaf=shared_leaf) second_parent = FooResource(name='second', leaf=shared_leaf) app = models.Application(stage='dev', resources=[first_parent, second_parent]) dep_builder = DependencyBuilder() deps = dep_builder.build_dependencies(app) assert deps == [shared_leaf, first_parent, second_parent]
def test_can_compares_with_identity_not_equality(self): first_leaf = LeafResource(name='same-name') second_leaf = LeafResource(name='same-name') first_parent = FooResource(name='first', leaf=first_leaf) second_parent = FooResource(name='second', leaf=second_leaf) app = models.Application(stage='dev', resources=[first_parent, second_parent]) dep_builder = DependencyBuilder() deps = dep_builder.build_dependencies(app) assert deps == [first_leaf, first_parent, second_leaf, second_parent]