Beispiel #1
0
 def test_save(self):
     data = {
         'name': 'Test Organization',
         'description': 'Test organization description',
         'website_url': 'http://example.com/',
     }
     f = OrganizationModelForm(data)
     f.save()
     self.assertEqual(f.instance.name, data['name'])
     self.assertEqual(f.instance.description, data['description'])
     self.assertEqual(f.instance.website_url, data['website_url'])
     org = Organization.objects.get(pk=f.instance.pk)
     self.assertEqual(org.name, data['name'])
     self.assertEqual(org.description, data['description'])
     self.assertEqual(org.website_url, data['website_url'])
Beispiel #2
0
 def test_update(self):
     org = create_organization(name="Test Organization", 
             description="Test organization description",
             website_url="http://example.com/")
     data = {
         'name': 'Test Organization 2',
         'description': 'Test organization description 2',
         'website_url': 'http://example.com/2/',
     }
     f = OrganizationModelForm(data, instance=org)
     f.save()
     self.assertEqual(org.name, data['name'])
     self.assertEqual(org.description, data['description'])
     self.assertEqual(org.website_url, data['website_url'])
     # Check that the changes were saved to the database
     org = Organization.objects.get(pk=org.pk)
     self.assertEqual(org.name, data['name'])
     self.assertEqual(org.description, data['description'])
     self.assertEqual(org.website_url, data['website_url'])