Facebook
From Melodic Dormouse, 2 Months ago, written in Python.
Embed
Download Paste or View Raw
Hits: 131
  1. assert_model_values(model_class, expected_values={}, **kwargs)
  2.  
  3. Przyklad uzycia:
  4. assert_model_values(Team, pk=12, expected={'name': 'FTW2'})
  5. assert_model_values(TeamMemberInSprint, team_capacity__sprint__sprint_id='256', expected={'participation': 69})
  6. assert_model_values(TeamMembership, user__username='szachun', team__name='AginoodleTeam' expected={'comment': 'pracownik miesiaca'})
  7.  
  8.  
  9. wstepna implementacja:
  10.  
  11. def assert_model_values(model_class, expected_values={}, **kwargs):
  12.     model_object = model_class.objects.get(**kwargs)
  13.  
  14.     for property_name, expected_value in expected_values.items():
  15.         self.assertEquals(getattr(model_object, property_name), expected_value)
  16.