@@ -70,6 +70,60 @@ def tearDown(self):
7070 self .session .query (Location ).delete ()
7171 self .session .commit ()
7272
73+ def test_add_dependency_parent (self ):
74+ """
75+ Testing that a parent extract dependency is created when adding dependency to extract.
76+ :return:
77+ """
78+ dependent_extract = ExtractTracker (
79+ process_run = self .process_run ,
80+ filename = "Dependent File.csv" ,
81+ location_name = "Test Location" ,
82+ location_path = "/home/test/extract_dir" ,
83+ )
84+ self .extract .add_dependency (
85+ dependency_type = "parent" , dependency = dependent_extract
86+ )
87+
88+ given_result = (
89+ self .session .query (ExtractDependency )
90+ .filter (
91+ ExtractDependency .child_extract_id == self .extract .extract .extract_id
92+ )
93+ .count ()
94+ )
95+
96+ expected_result = 1
97+
98+ self .assertEqual (expected_result , given_result )
99+
100+ def test_add_dependency_child (self ):
101+ """
102+ Testing that a child extract dependency is created when adding dependency to extract.
103+ :return:
104+ """
105+ dependent_extract = ExtractTracker (
106+ process_run = self .process_run ,
107+ filename = "Dependent File.csv" ,
108+ location_name = "Test Location" ,
109+ location_path = "/home/test/extract_dir" ,
110+ )
111+ self .extract .add_dependency (
112+ dependency_type = "child" , dependency = dependent_extract
113+ )
114+
115+ given_result = (
116+ self .session .query (ExtractDependency )
117+ .filter (
118+ ExtractDependency .parent_extract_id == self .extract .extract .extract_id
119+ )
120+ .count ()
121+ )
122+
123+ expected_result = 1
124+
125+ self .assertEqual (expected_result , given_result )
126+
73127 def test_initialization_no_location_no_location_path (self ):
74128 """
75129 Testing that if no location or location path is set, an error is thrown.
0 commit comments