@@ -489,3 +489,34 @@ def test_datafile_unit_has_its_own_wording_for_an_unknown_reader(
489489 )(ExecutionContext ())
490490
491491 assert str (excinfo .value ) == "DataLoader 'NoSuchLoader' not found in registry."
492+
493+
494+ def test_datafile_unit_rejects_a_component_that_is_not_a_reader (
495+ datafile_rows , csv_file , tmp_path
496+ ):
497+ """A registered component of some other kind is still not a reader.
498+
499+ The registry's ``registry[name]`` indexer searches every type at once, so
500+ looking the name up that way would find, say, a metric and call it as if it
501+ could parse a file. The lookup is deliberately scoped to the readers.
502+ """
503+ from DashAI .back .core .enums .status import DatafileStatus
504+ from DashAI .back .dataloaders .classes .csv_dataloader import CSVDataLoader
505+ from DashAI .back .dependencies .registry import ComponentRegistry
506+ from DashAI .back .metrics .classification .accuracy import Accuracy
507+
508+ di ["component_registry" ] = ComponentRegistry (
509+ initial_components = [CSVDataLoader , Accuracy ]
510+ )
511+ datafile_rows [7 ] = _DatafileRow (str (tmp_path ), DatafileStatus .READY )
512+ try :
513+ with pytest .raises (JobError ) as excinfo :
514+ LoadDatafileDatasetUnit (
515+ dataloader = {"component" : "Accuracy" , "params" : {}},
516+ datafile_id = 7 ,
517+ selected_file = "data.csv" ,
518+ )(ExecutionContext ())
519+ finally :
520+ del di ["component_registry" ]
521+
522+ assert str (excinfo .value ) == "DataLoader 'Accuracy' not found in registry."
0 commit comments