@@ -251,20 +251,6 @@ def test_stratigraphy_requires_well(self):
251251 session .add (record )
252252 session .flush ()
253253
254- def test_radionuclides_requires_sample_info (self ):
255- """
256- @radionuclides
257- Scenario: Radionuclide results require chemistry sample info
258- """
259- with session_ctx () as session :
260- with pytest .raises (ValueError , match = "requires a chemistry_sample_info_id" ):
261- record = NMA_Radionuclides (
262- nma_sample_pt_id = uuid .uuid4 (),
263- chemistry_sample_info_id = None , # This should raise ValueError
264- )
265- session .add (record )
266- session .flush ()
267-
268254 def test_associated_data_requires_well (self ):
269255 """
270256 @associated-data
@@ -375,35 +361,6 @@ def test_well_navigates_to_stratigraphy_logs(self, well_for_relationships):
375361 assert len (well .stratigraphy_logs ) >= 1
376362 assert any (s .nma_point_id == "NAVSTRAT1" for s in well .stratigraphy_logs )
377363
378- def test_sample_info_navigates_to_radionuclides (self , well_for_relationships ):
379- """Chemistry sample info can navigate to its radionuclide results."""
380- with session_ctx () as session :
381- well = session .merge (well_for_relationships )
382-
383- # Create a chemistry sample for the thing (chemistry FKs to Thing)
384- chem_sample = NMA_Chemistry_SampleInfo (
385- nma_sample_pt_id = uuid .uuid4 (),
386- nma_sample_point_id = "NAVRAD01" , # Required, max 10 chars
387- thing_id = well .id ,
388- )
389- session .add (chem_sample )
390- session .commit ()
391- session .refresh (chem_sample )
392-
393- # Create radionuclide record for this well using the chemistry_sample_info_id
394- radio = NMA_Radionuclides (
395- nma_global_id = uuid .uuid4 (),
396- chemistry_sample_info_id = chem_sample .id ,
397- nma_sample_pt_id = chem_sample .nma_sample_pt_id ,
398- )
399- session .add (radio )
400- session .commit ()
401- session .refresh (chem_sample )
402-
403- # Navigate through relationship
404- assert hasattr (chem_sample , "radionuclides" )
405- assert len (chem_sample .radionuclides ) >= 1
406-
407364 def test_well_navigates_to_associated_data (self , well_for_relationships ):
408365 """Well can navigate to its associated data."""
409366 with session_ctx () as session :
@@ -444,6 +401,42 @@ def test_well_navigates_to_soil_rock_results(self, well_for_relationships):
444401 assert any (s .nma_point_id == "NAV-SOIL-01" for s in well .soil_rock_results )
445402
446403
404+ class TestChemistrySampleInfoNavigation :
405+ """
406+ @relationships
407+ Scenario: Chemistry sample info can access its related records
408+ """
409+
410+ def test_sample_info_navigates_to_radionuclides (self , well_for_relationships ):
411+ """Chemistry sample info can navigate to its radionuclide results."""
412+ with session_ctx () as session :
413+ well = session .merge (well_for_relationships )
414+
415+ # Create a chemistry sample for the thing (chemistry FKs to Thing)
416+ chem_sample = NMA_Chemistry_SampleInfo (
417+ nma_sample_pt_id = uuid .uuid4 (),
418+ nma_sample_point_id = "NAVRAD01" , # Required, max 10 chars
419+ thing_id = well .id ,
420+ )
421+ session .add (chem_sample )
422+ session .commit ()
423+ session .refresh (chem_sample )
424+
425+ # Create radionuclide record using the chemistry_sample_info_id
426+ radio = NMA_Radionuclides (
427+ nma_global_id = uuid .uuid4 (),
428+ chemistry_sample_info_id = chem_sample .id ,
429+ nma_sample_pt_id = chem_sample .nma_sample_pt_id ,
430+ )
431+ session .add (radio )
432+ session .commit ()
433+ session .refresh (chem_sample )
434+
435+ # Navigate through relationship
436+ assert hasattr (chem_sample , "radionuclides" )
437+ assert len (chem_sample .radionuclides ) >= 1
438+
439+
447440# =============================================================================
448441# Deleting a Well Removes Related Records (Cascade Delete)
449442# =============================================================================
@@ -680,3 +673,29 @@ def test_deleting_well_cascades_to_soil_rock_results(self):
680673 # Verify soil/rock results were also deleted
681674 orphan = session .get (NMA_Soil_Rock_Results , soil_id )
682675 assert orphan is None , "Soil/rock results should be deleted with well"
676+
677+
678+ # =============================================================================
679+ # Chemistry Children Require Sample Info
680+ # =============================================================================
681+
682+
683+ class TestChemistryChildrenRequireSampleInfo :
684+ """
685+ @radionuclides
686+ Scenario: Chemistry children require a parent sample info
687+ """
688+
689+ def test_radionuclides_requires_sample_info (self ):
690+ """
691+ @radionuclides
692+ Scenario: Radionuclide results require chemistry sample info
693+ """
694+ with session_ctx () as session :
695+ with pytest .raises (ValueError , match = "requires a chemistry_sample_info_id" ):
696+ record = NMA_Radionuclides (
697+ nma_sample_pt_id = uuid .uuid4 (),
698+ chemistry_sample_info_id = None , # This should raise ValueError
699+ )
700+ session .add (record )
701+ session .flush ()
0 commit comments