title: assert_equal NameError 'db' is not defined when testing MongoDB function
body: <p>I have a problem with the assert_equal which is indicating that name 'db' is not defined.</p>
  <p>The function is testing my function that I have written that returns the percentage of businesses that have a rating value of 5. When I run the function as written, the function returns expected values and percentages which is great but I need the assert_equal to pass too.</p>
  <p>I have tried using</p>
  <p>db.[collection].count - invalid syntax
  collection.count Total number of business with a rating value - 0 ie not calculating the correct number
  db.collection.count same as above</p>
  <p>So my own function then fails</p>
  <p>Any suggestions are gratefully received.</p>
  <p>I am very new to python and MongoDB.</p>
  <p>Avril</p>
  <p>I have removed the password and client information for security reasons.</p>
  <pre><code>def get_rating_value_percentage(collection):
  &quot;&quot;&quot;
  Return a float between 0 and 1 of the amount with a RatingValue of 5
  &quot;&quot;&quot;
  
  password = 
  client = 
  db = some_data
  
  i=0.00
  
  # testing print (type(i)) checking to see that is set up as a float
  # testing print(type(collection))
  
  total_business_s_ratingvalue = db[collection].count('RatingValue')
  print ('Total number of businesses with a rating value - %s' %total_business_s_ratingvalue)
  total_business_s_ratingvaluefive = db[collection].count({'RatingValue' :5})
  print ('Total number of business with a rating value of 5 - %s'%total_business_s_ratingvaluefive )
  i = total_business_s_ratingvaluefive / total_business_s_ratingvalue
  print ('Percentage of business in collection %s with a rating value of five' %i )
  return str(i) # this is for the tests lower down - it is asking for a string so converted i to a string 
  </code></pre>
  <p>Percentage_ratingvalue_five=get_rating_value_percentage('uk')
  print (Percentage_ratingvalue_five)</p>