Skip to content

Commit 1818397

Browse files
authored
Merge pull request #759 from atlanhq/APP-9677
APP-9677: Fixed type for `LineageListRequest.relation_attributes` to be `Optional[List[str]]`
2 parents 3861651 + 581640d commit 1818397

2 files changed

Lines changed: 137 additions & 13 deletions

File tree

pyatlan/model/lineage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ class LineageListRequest(SearchRequest):
276276
"Any sub-graphs beyond the entities filtered out by these filters will not be included"
277277
"in the lineage result.",
278278
)
279-
relation_attributes: Optional[str] = Field(
279+
relation_attributes: Optional[List[str]] = Field(
280280
default=None,
281281
description="List of related attributes to be returned for each asset",
282282
)

tests/unit/test_lineage.py

Lines changed: 136 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
FilterList,
3333
FluentLineage,
3434
LineageGraph,
35+
LineageListRequest,
3536
LineageRelation,
3637
LineageResponse,
3738
)
@@ -596,7 +597,8 @@ def test_eq(
596597
GOOD_EXCLUDE_MEANINGS = False
597598
GOOD_EXCLUDE_CLASSIFICATIONS = True
598599
GOOD_INCLUDES_IN_RESULTS: List[AtlanField] = []
599-
GOOD_INCLUDE_ON_RESULTS: List[LineageFilter] = []
600+
GOOD_INCLUDES_ON_RESULTS: List[LineageFilter] = []
601+
GOOD_INCLUDES_ON_RELATIONS: List[AtlanField] = []
600602
GOOD_WHERE_ASSETS: List[LineageFilter] = []
601603
GOOD_WHERE_RELATIONSHIPS: List[LineageFilter] = []
602604
BAD_STRING = True
@@ -616,7 +618,7 @@ def sut(self) -> FluentLineage:
616618

617619
@pytest.mark.parametrize(
618620
"starting_guid, depth, direction, size, exclude_meanings, exclude_atlan_tags, includes_in_results, "
619-
"includes_on_results, where_assets, where_relationships, message",
621+
"includes_on_results, includes_on_relations, where_assets, where_relationships, message",
620622
[
621623
(
622624
None,
@@ -626,7 +628,8 @@ def sut(self) -> FluentLineage:
626628
GOOD_EXCLUDE_MEANINGS,
627629
GOOD_EXCLUDE_CLASSIFICATIONS,
628630
GOOD_INCLUDES_IN_RESULTS,
629-
GOOD_INCLUDE_ON_RESULTS,
631+
GOOD_INCLUDES_ON_RESULTS,
632+
GOOD_INCLUDES_ON_RELATIONS,
630633
GOOD_WHERE_ASSETS,
631634
GOOD_WHERE_RELATIONSHIPS,
632635
r"1 validation error for Init\nstarting_guid\n none is not an allowed value "
@@ -640,7 +643,8 @@ def sut(self) -> FluentLineage:
640643
GOOD_EXCLUDE_MEANINGS,
641644
GOOD_EXCLUDE_CLASSIFICATIONS,
642645
GOOD_INCLUDES_IN_RESULTS,
643-
GOOD_INCLUDE_ON_RESULTS,
646+
GOOD_INCLUDES_ON_RESULTS,
647+
GOOD_INCLUDES_ON_RELATIONS,
644648
GOOD_WHERE_ASSETS,
645649
GOOD_WHERE_RELATIONSHIPS,
646650
r"1 validation error for Init\nstarting_guid\n str type expected \(type=type_error.str\)",
@@ -653,7 +657,8 @@ def sut(self) -> FluentLineage:
653657
GOOD_EXCLUDE_MEANINGS,
654658
GOOD_EXCLUDE_CLASSIFICATIONS,
655659
GOOD_INCLUDES_IN_RESULTS,
656-
GOOD_INCLUDE_ON_RESULTS,
660+
GOOD_INCLUDES_ON_RESULTS,
661+
GOOD_INCLUDES_ON_RELATIONS,
657662
GOOD_WHERE_ASSETS,
658663
GOOD_WHERE_RELATIONSHIPS,
659664
r"1 validation error for Init\ndepth\n value is not a valid integer \(type=type_error.integer\)",
@@ -666,7 +671,8 @@ def sut(self) -> FluentLineage:
666671
GOOD_EXCLUDE_MEANINGS,
667672
GOOD_EXCLUDE_CLASSIFICATIONS,
668673
GOOD_INCLUDES_IN_RESULTS,
669-
GOOD_INCLUDE_ON_RESULTS,
674+
GOOD_INCLUDES_ON_RESULTS,
675+
GOOD_INCLUDES_ON_RELATIONS,
670676
GOOD_WHERE_ASSETS,
671677
GOOD_WHERE_RELATIONSHIPS,
672678
r"1 validation error for Init\ndirection\n value is not a valid enumeration member; permitted:",
@@ -679,7 +685,8 @@ def sut(self) -> FluentLineage:
679685
GOOD_EXCLUDE_MEANINGS,
680686
GOOD_EXCLUDE_CLASSIFICATIONS,
681687
GOOD_INCLUDES_IN_RESULTS,
682-
GOOD_INCLUDE_ON_RESULTS,
688+
GOOD_INCLUDES_ON_RESULTS,
689+
GOOD_INCLUDES_ON_RELATIONS,
683690
GOOD_WHERE_ASSETS,
684691
GOOD_WHERE_RELATIONSHIPS,
685692
r"1 validation error for Init\nsize\n value is not a valid integer \(type=type_error.integer\)",
@@ -692,7 +699,8 @@ def sut(self) -> FluentLineage:
692699
BAD_BOOL,
693700
GOOD_EXCLUDE_CLASSIFICATIONS,
694701
GOOD_INCLUDES_IN_RESULTS,
695-
GOOD_INCLUDE_ON_RESULTS,
702+
GOOD_INCLUDES_ON_RESULTS,
703+
GOOD_INCLUDES_ON_RELATIONS,
696704
GOOD_WHERE_ASSETS,
697705
GOOD_WHERE_RELATIONSHIPS,
698706
r"1 validation error for Init\nexclude_meanings\n value is not a valid boolean "
@@ -706,7 +714,8 @@ def sut(self) -> FluentLineage:
706714
GOOD_EXCLUDE_MEANINGS,
707715
BAD_BOOL,
708716
GOOD_INCLUDES_IN_RESULTS,
709-
GOOD_INCLUDE_ON_RESULTS,
717+
GOOD_INCLUDES_ON_RESULTS,
718+
GOOD_INCLUDES_ON_RELATIONS,
710719
GOOD_WHERE_ASSETS,
711720
GOOD_WHERE_RELATIONSHIPS,
712721
r"1 validation error for Init\nexclude_atlan_tags\n value is not a valid boolean "
@@ -720,7 +729,8 @@ def sut(self) -> FluentLineage:
720729
GOOD_EXCLUDE_MEANINGS,
721730
GOOD_EXCLUDE_CLASSIFICATIONS,
722731
BAD_LINEAGE_FILTER_LIST,
723-
GOOD_INCLUDE_ON_RESULTS,
732+
GOOD_INCLUDES_ON_RESULTS,
733+
GOOD_INCLUDES_ON_RELATIONS,
724734
GOOD_WHERE_ASSETS,
725735
GOOD_WHERE_RELATIONSHIPS,
726736
r"3 validation errors for Init\nincludes_in_results",
@@ -734,6 +744,7 @@ def sut(self) -> FluentLineage:
734744
GOOD_EXCLUDE_CLASSIFICATIONS,
735745
GOOD_INCLUDES_IN_RESULTS,
736746
BAD_LINEAGE_FILTER_LIST,
747+
GOOD_INCLUDES_ON_RELATIONS,
737748
GOOD_WHERE_ASSETS,
738749
GOOD_WHERE_RELATIONSHIPS,
739750
r"4 validation errors for Init\nincludes_on_results",
@@ -746,7 +757,22 @@ def sut(self) -> FluentLineage:
746757
GOOD_EXCLUDE_MEANINGS,
747758
GOOD_EXCLUDE_CLASSIFICATIONS,
748759
GOOD_INCLUDES_IN_RESULTS,
749-
GOOD_INCLUDE_ON_RESULTS,
760+
GOOD_INCLUDES_ON_RESULTS,
761+
BAD_LINEAGE_FILTER_LIST,
762+
GOOD_WHERE_ASSETS,
763+
GOOD_WHERE_RELATIONSHIPS,
764+
r"4 validation errors for Init\nincludes_on_relations",
765+
),
766+
(
767+
GOOD_GUID,
768+
GOOD_DEPTH,
769+
LineageDirection.DOWNSTREAM,
770+
GOOD_SIZE,
771+
GOOD_EXCLUDE_MEANINGS,
772+
GOOD_EXCLUDE_CLASSIFICATIONS,
773+
GOOD_INCLUDES_IN_RESULTS,
774+
GOOD_INCLUDES_ON_RESULTS,
775+
GOOD_INCLUDES_ON_RELATIONS,
750776
BAD_LINEAGE_FILTER_LIST,
751777
GOOD_WHERE_RELATIONSHIPS,
752778
r"3 validation errors for Init\nwhere_assets",
@@ -759,7 +785,8 @@ def sut(self) -> FluentLineage:
759785
GOOD_EXCLUDE_MEANINGS,
760786
GOOD_EXCLUDE_CLASSIFICATIONS,
761787
GOOD_INCLUDES_IN_RESULTS,
762-
GOOD_INCLUDE_ON_RESULTS,
788+
GOOD_INCLUDES_ON_RESULTS,
789+
GOOD_INCLUDES_ON_RELATIONS,
763790
GOOD_WHERE_ASSETS,
764791
BAD_LINEAGE_FILTER_LIST,
765792
r"3 validation errors for Init\nwhere_relationships",
@@ -776,6 +803,7 @@ def test_init_with_bad_parameters_raise_value_error(
776803
exclude_atlan_tags,
777804
includes_in_results,
778805
includes_on_results,
806+
includes_on_relations,
779807
where_assets,
780808
where_relationships,
781809
message,
@@ -790,10 +818,106 @@ def test_init_with_bad_parameters_raise_value_error(
790818
exclude_atlan_tags=exclude_atlan_tags,
791819
includes_on_results=includes_on_results,
792820
includes_in_results=includes_in_results,
821+
includes_on_relations=includes_on_relations,
793822
where_assets=where_assets,
794823
where_relationships=where_relationships,
795824
)
796825

826+
@pytest.mark.parametrize(
827+
"starting_guid, depth, direction, size, exclude_meanings, exclude_atlan_tags, includes_in_results, "
828+
"includes_on_results, includes_on_relations, where_assets, where_relationships",
829+
[
830+
(
831+
GOOD_GUID,
832+
GOOD_DEPTH,
833+
LineageDirection.DOWNSTREAM,
834+
GOOD_SIZE,
835+
GOOD_EXCLUDE_MEANINGS,
836+
GOOD_EXCLUDE_CLASSIFICATIONS,
837+
GOOD_INCLUDES_IN_RESULTS,
838+
GOOD_INCLUDES_ON_RESULTS,
839+
["some_field", "another_field"],
840+
GOOD_WHERE_ASSETS,
841+
GOOD_WHERE_RELATIONSHIPS,
842+
),
843+
(
844+
GOOD_GUID,
845+
GOOD_DEPTH,
846+
LineageDirection.DOWNSTREAM,
847+
GOOD_SIZE,
848+
GOOD_EXCLUDE_MEANINGS,
849+
GOOD_EXCLUDE_CLASSIFICATIONS,
850+
GOOD_INCLUDES_IN_RESULTS,
851+
GOOD_INCLUDES_ON_RESULTS,
852+
[Asset.DESCRIPTION, Asset.OWNER_GROUPS],
853+
GOOD_WHERE_ASSETS,
854+
GOOD_WHERE_RELATIONSHIPS,
855+
),
856+
(
857+
GOOD_GUID,
858+
GOOD_DEPTH,
859+
LineageDirection.DOWNSTREAM,
860+
GOOD_SIZE,
861+
GOOD_EXCLUDE_MEANINGS,
862+
GOOD_EXCLUDE_CLASSIFICATIONS,
863+
GOOD_INCLUDES_IN_RESULTS,
864+
GOOD_INCLUDES_ON_RESULTS,
865+
"some_field",
866+
GOOD_WHERE_ASSETS,
867+
GOOD_WHERE_RELATIONSHIPS,
868+
),
869+
(
870+
GOOD_GUID,
871+
GOOD_DEPTH,
872+
LineageDirection.DOWNSTREAM,
873+
GOOD_SIZE,
874+
GOOD_EXCLUDE_MEANINGS,
875+
GOOD_EXCLUDE_CLASSIFICATIONS,
876+
GOOD_INCLUDES_IN_RESULTS,
877+
GOOD_INCLUDES_ON_RESULTS,
878+
Asset.NAME,
879+
GOOD_WHERE_ASSETS,
880+
GOOD_WHERE_RELATIONSHIPS,
881+
),
882+
],
883+
)
884+
def test_init_and_request_for_includes_on_relations(
885+
self,
886+
starting_guid,
887+
depth,
888+
direction,
889+
size,
890+
exclude_meanings,
891+
exclude_atlan_tags,
892+
includes_in_results,
893+
includes_on_results,
894+
includes_on_relations,
895+
where_assets,
896+
where_relationships,
897+
):
898+
fl = FluentLineage(
899+
starting_guid=starting_guid,
900+
depth=depth,
901+
direction=direction,
902+
size=size,
903+
exclude_meanings=exclude_meanings,
904+
exclude_atlan_tags=exclude_atlan_tags,
905+
includes_on_results=includes_on_results,
906+
includes_in_results=includes_in_results,
907+
includes_on_relations=includes_on_relations,
908+
where_assets=where_assets,
909+
where_relationships=where_relationships,
910+
)
911+
assert isinstance(fl.request, LineageListRequest)
912+
if isinstance(includes_on_relations, str) or isinstance(
913+
includes_on_relations, AtlanField
914+
):
915+
assert (
916+
len(fl.request.relation_attributes) == [includes_on_relations].__len__()
917+
)
918+
else:
919+
assert len(fl.request.relation_attributes) == len(includes_on_relations)
920+
797921
def test_request_with_defaults(self, sut: FluentLineage):
798922
request = sut.request
799923

0 commit comments

Comments
 (0)