Commit 69f189dfc4cddf918ac089f0df76915b7138b5de

Authored by Luke Baker
1 parent 9f12bfbb

ignore a few more tests for certain questions

Any question with votes before 2010-02-17 didn't keep track of the
loser.  We need to ignore some tests for those questions.
Showing 1 changed file with 18 additions and 13 deletions   Show diff stats
lib/tasks/test_api.rake
... ... @@ -349,7 +349,7 @@ namespace :test_api do
349 349  
350 350 email_text = "Conducted the following tests on API data and found the following results\n" + "For each of the #{questions.length} questions in the database: \n"
351 351 errors.each do |e|
352   - email_text += " Test FAILED: " + e + "\n"
  352 + email_text += " Test FAILED:\n" + e + "\n"
353 353 end
354 354  
355 355 successes.uniq.each do |s|
... ... @@ -381,6 +381,9 @@ namespace :test_api do
381 381 total_scores_gte_fifty= 0
382 382 total_scores_lte_fifty= 0
383 383 error_bool = false
  384 + # votes before 2010-02-17 have null loser_choice_id therefore we
  385 + # want to ignore some tests for any question with votes before 2010-02-17
  386 + question_has_votes_before_2010_02_17 = question.votes.count(:conditions => ["created_at < ?", '2010-02-17']) > 0
384 387  
385 388 question.choices.each do |choice|
386 389  
... ... @@ -430,7 +433,7 @@ namespace :test_api do
430 433 # votes before 2010-02-17 have null loser_choice_id
431 434 # therefore we want to ignore this test for any question with votes
432 435 # prior to 2010-02-17
433   - if question.votes.count(:conditions => ["created_at < ?", '2010-02-17']) == 0
  436 + unless question_has_votes_before_2010_02_17
434 437 if (choice.losses != question.votes.count(:conditions => {:loser_choice_id => choice.id}))
435 438 error_message += "Error!: Cached choice losses != actual choice losses for choice #{choice.id}\n"
436 439 error_bool= true
... ... @@ -440,19 +443,21 @@ namespace :test_api do
440 443 end
441 444  
442 445  
443   - if (2*total_wins != total_votes)
444   - error_message += "Error 1: 2 x Total Wins != Total votes\n"
445   - error_bool= true
446   - end
  446 + unless question_has_votes_before_2010_02_17
  447 + if (2*total_wins != total_votes)
  448 + error_message += "Error 1: 2 x Total Wins != Total votes\n"
  449 + error_bool= true
  450 + end
447 451  
448   - if(total_votes % 2 != 0)
449   - error_message += "Error 2: Total votes is not Even!\n"
450   - error_bool= true
451   - end
  452 + if(total_votes % 2 != 0)
  453 + error_message += "Error 2: Total votes is not Even!\n"
  454 + error_bool= true
  455 + end
452 456  
453   - if(total_votes != 2* question.votes_count)
454   - error_message += "Error 3: Total votes != 2 x # vote objects\n"
455   - error_bool = true
  457 + if(total_votes != 2* question.votes_count)
  458 + error_message += "Error 3: Total votes != 2 x # vote objects\n"
  459 + error_bool = true
  460 + end
456 461 end
457 462  
458 463 if(total_generated_prompts_on_right != total_generated_prompts_on_right)
... ...