Ejemplo n.º 1
0
 def test_newrack_with_bad_source_but_no_email(self):
     from fixcity.bmabr.views import _newrack
     from fixcity.bmabr.models import NEED_SOURCE_OR_EMAIL
     from fixcity.bmabr.models import NEED_LOGGEDIN_OR_EMAIL
     result = _newrack({'source': 999999999}, {})
     self.assertEqual(
         result['errors'].get('source'),
         [u'Select a valid choice. That choice is not one of the available choices.'])
     self.assertEqual(result['errors'].get('email'), [NEED_LOGGEDIN_OR_EMAIL])
     self.assertEqual(result['errors'].get('__all__'), [NEED_SOURCE_OR_EMAIL])
Ejemplo n.º 2
0
 def test_newrack_no_data(self):
     from fixcity.bmabr.views import _newrack
     from fixcity.bmabr.models import NEED_SOURCE_OR_EMAIL
     result = _newrack({}, {})
     self.failUnless(result.has_key('errors'))
     self.assertEqual(result['errors']['title'],
                      [u'This field is required.'])
     self.assertEqual(result['errors']['address'],
                      [u'This field is required.'])
     self.assertEqual(result['errors']['date'],
                      [u'This field is required.'])
     self.assertEqual(result['errors']['__all__'], [NEED_SOURCE_OR_EMAIL])
     self.assertEqual(result['rack'], None)
Ejemplo n.º 3
0
 def test_newrack_working(self):
     from fixcity.bmabr.views import _newrack
     from fixcity.bmabr.models import Source
     source = Source()
     source.name = 'unknown source type'
     source.save() # needed to get an ID
     result = _newrack({'title': 'footitle',
                        'address': '123 W 12th st, New York, NY',
                        'date': '2009-11-18 12:33',
                        'source': source.id,
                        'location': Point(20.0, 20.0, srid=SRID),
                        }, {})
     self.assertEqual(result['errors'], {})
     self.failUnless(result.get('message'))
     self.failUnless(result.get('rack'))
Ejemplo n.º 4
0
 def test_newrack_with_email_but_no_source(self):
     from fixcity.bmabr.views import _newrack
     result = _newrack({'email': '*****@*****.**'}, {})
     self.assertEqual(result['errors'].get('email'), None)
     self.assertEqual(result['errors'].get('__all__'), None)
     self.assertEqual(result['errors'].get('source'), None)