docstr: Test if the component runs correctly with scores in the Document score field.
docstr_tok: ["Test","if","the","component","runs","correctly","with","scores","in","the","Document","score","field","."]
code: def test_run_scores(self):
      """
      Test if the component runs correctly with scores in the Document score field.
      """
      sampler = TopPSampler(top_p=0.99)
      docs = [
          Document(content="Berlin", score=-10.6),
          Document(content="Belgrade", score=-8.9),
          Document(content="Sarajevo", score=-4.6),
      ]
  
      random.shuffle(docs)
      sorted_scores = sorted([doc.score for doc in docs], reverse=True)
  
      # top_p = 0.99 will get the top 1 document
      output = sampler.run(documents=docs)
      docs_filtered = output["documents"]
      assert len(docs_filtered) == 1
      assert docs_filtered[0].content == "Sarajevo"
  
      assert [doc.score for doc in docs_filtered] == sorted_scores[:1]
  
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 2 for calling the TestTopPSampler obj's underlying member method code with example usage: obj.test_run_scores() without return types