Skip to content

Commit

Permalink
Fix utils manager test case
Browse files Browse the repository at this point in the history
  • Loading branch information
jc0n committed Nov 1, 2011
1 parent a17c0ef commit cefe57c
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions pr_services/pr_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from datetime import datetime, date, timedelta
import hashlib
import inspect
import operator
import os
import sys
import time
Expand Down Expand Up @@ -3260,26 +3261,31 @@ def setUp(self):
self.utils_manager = facade.managers.UtilsManager()

def test_get_choices(self):
get_choices = self.utils_manager.get_choices

# check the invalid model name case
self.assertRaises(exceptions.FieldNameNotFoundException,
self.utils_manager.get_choices,
'not_a_model', 'aspect_ratio')
get_choices, 'not_a_model', 'aspect_ratio')

self.assertRaises(exceptions.FieldNameNotFoundException,
self.utils_manager.get_choices, 'Assignment', 'not_a_field')

get_choices = self.utils_manager.get_choices
get_choices, 'Assignment', 'not_a_field')

# check that we gen an empty list for a field that has no choices
choices = get_choices('Assignment', 'date_started')
self.assertEquals(len(choices), 0)

# check a couple of fields with choices
choices = get_choices('Assignment', 'status')
self.assertEquals(pr_models.Assignment.STATUS_CHOICES, choices)
def django_choices(s):
choice = operator.itemgetter(0)
return map(choice, s)

expected = django_choices(pr_models.Assignment.STATUS_CHOICES)
test = get_choices('Assignment', 'status')
self.assertEqual(test, expected)

choices = get_choices('Domain', 'password_hash_type')
self.assertEquals(pr_models.Domain.PASSWORD_HASH_TYPE_CHOICES, choices)
expected = django_choices(pr_models.Domain.PASSWORD_HASH_TYPE_CHOICES)
test = get_choices('Domain', 'password_hash_type')
self.assertEquals(test, expected)


################################################################################################################################################
Expand Down

0 comments on commit cefe57c

Please sign in to comment.