@@ -109,8 +109,11 @@ defmodule DiffoExample.Access.PathTest do
109109 # now assign a port from a line card
110110 [ _dslam , line_card ] = create_dslam_with_line_card ( "QDONC-0001" , tl ( places ) , parties )
111111
112+ # path-as-assignee names its slot :port when requesting the port-assignment
113+ # from the line card. This alias lets the InheritedCharacteristic calc
114+ # traverse path → port → card (and transitively card → slot → shelf).
112115 Access . assign_port! ( line_card , % {
113- assignment: % Assignment { assignee_id: path . id , operation: :auto_assign }
116+ assignment: % Assignment { assignee_id: path . id , alias: :port , operation: :auto_assign }
114117 } )
115118
116119 # 5 cables each assigned a pair to the path, plus 1 line card assigned a port
@@ -124,6 +127,19 @@ defmodule DiffoExample.Access.PathTest do
124127
125128 { :ok , path } = Access . get_path_by_id ( path . id )
126129
130+ # the path brings up its card and (transitively) its shelf via the
131+ # port-then-slot assignment chain — each instance shows itself, the path
132+ # also shows what's brought up from below.
133+ { :ok , path_with_brought_up } =
134+ Ash . load ( path , [ :card , :shelf , :port ] )
135+
136+ [ % { family: :ISAM , model: "EBLT48" , technology: :adsl2Plus } ] = path_with_brought_up . card
137+
138+ [ % { device_name: "QDONC-0001" , family: :ISAM , model: "ISAM7330" , technology: :DSLAM } ] =
139+ path_with_brought_up . shelf
140+
141+ assert path_with_brought_up . port == [ 1 ]
142+
127143 encoding =
128144 Jason . encode! ( path )
129145 |> Diffo.Util . summarise_dates ( )
@@ -220,18 +236,26 @@ defmodule DiffoExample.Access.PathTest do
220236
221237 shelf =
222238 Access . define_shelf! ( shelf , % {
223- characteristic_value_updates: [ slots: [ first: 1 , last: 10 , assignable_type: "LineCard" ] ]
239+ characteristic_value_updates: [
240+ shelf: [ device_name: name , family: :ISAM , model: "ISAM7330" , technology: :DSLAM ] ,
241+ slots: [ first: 1 , last: 10 , assignable_type: "LineCard" ]
242+ ]
224243 } )
225244
226245 card = Access . build_card! ( % { name: "dslam line card #{ name } 1" } )
227246
228247 card =
229248 Access . define_card! ( card , % {
230- characteristic_value_updates: [ ports: [ first: 1 , last: 48 , assignable_type: "ADSL2+" ] ]
249+ characteristic_value_updates: [
250+ card: [ family: :ISAM , model: "EBLT48" , technology: :adsl2Plus ] ,
251+ ports: [ first: 1 , last: 48 , assignable_type: "ADSL2+" ]
252+ ]
231253 } )
232254
255+ # card-as-assignee names its slot :slot when requesting; alias lets
256+ # downstream calculations traverse the assignment by name.
233257 Access . assign_slot! ( shelf , % {
234- assignment: % Assignment { assignee_id: card . id , operation: :auto_assign }
258+ assignment: % Assignment { assignee_id: card . id , alias: :slot , operation: :auto_assign }
235259 } )
236260
237261 [ shelf , card ]
0 commit comments