示例#1
0
    def test_existing_source(self):
        from fixcity.bmabr.models import Source, TwitterSource
        from fixcity.bmabr.views import source_factory
        existing = Source()
        existing.name = 'misc source'
        existing.save()
        dupe, is_new = source_factory({'source': existing.id})
        self.assertEqual(dupe, existing)
        self.failIf(is_new)

        # It should work also with subclasses of Source...
        twit = TwitterSource(status_id=12345, name='twitter')
        twit.save()
        self.assertEqual((twit, False), source_factory({'source': twit.id}))
示例#2
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'))