docstr: Test if the component runs correctly with scores missing from the metadata yet being specified in the
  score_field.
docstr_tok: ["Test","if","the","component","runs","correctly","with","scores","missing","from","the","metadata","yet","being","specified","in","the","score_field","."]
code: def test_run_scores_no_metadata_present(self):
      """
      Test if the component runs correctly with scores missing from the metadata yet being specified in the
      score_field.
      """
      sampler = TopPSampler(top_p=0.95, score_field="similarity_score")
      docs = [
          Document(content="Berlin", score=-10.6),
          Document(content="Belgrade", score=-8.9),
          Document(content="Sarajevo", score=-4.6),
      ]
      with pytest.raises(
          ComponentError,
          match="Score field 'similarity_score' not found",
      ):
          sampler.run(documents=docs)
  
file_path: haystack/test/components/samplers/test_top_p.py
imports: import random
  import pytest
  from haystack import Document, ComponentError
  from haystack.components.samplers.top_p import TopPSampler
label_desc: Use image node_id 5 for calling the TestTopPSampler obj's underlying member method code with example usage: obj.test_run_scores_no_metadata_present() without return types