def test_should_see_valid( self ):
     global db
     mappings = list( Mapping.view("mapping/new") )
     self.assertEqual( 3, len(mappings) )
     self.assertEqual( "route", mappings[0].mapping_type )
     self.assertTrue( validate(mappings[0]) )
     self.assertEqual( "stop", mappings[1].mapping_type )
     self.assertTrue( validate(mappings[1]) )
     self.assertEqual( "vehicle", mappings[2].mapping_type )
     self.assertTrue( validate(mappings[2]) )
 def test_should_see_duplicate( self ):
     global db
     mappings = list( Mapping.view("mapping/new") )
     self.assertEqual( 2, len(mappings) )
     self.assertTrue( validate(mappings[0]) )
     mappings[0].status= 'valid'
     mappings[0].save()
     try:
         self.assertFalse( validate( mappings[1] ) )
         self.fail( "Did not raise exception" )
     except Invalid_Mapping as ex:
         self.assertEqual( "duplicate type and effective date", ex.message )
 def test_should_see_invalid_mappings( self ):
     global db
     mappings = list( Mapping.view("mapping/new") )
     self.assertEqual( 3, len(mappings) )
     try:
         self.assertFalse( validate( mappings[0] ) )
         self.fail( "Did not raise exception" )
     except ResourceNotFound as ex:
         self.assertEqual( "Document is missing attachment", ex.message )
     try:
         self.assertFalse( validate( mappings[1] ) )
         self.fail( "Did not raise exception" )
     except Invalid_Mapping as ex:
         self.assertEqual( 'unknown type: invalid_type', ex.message )
     try:
         self.assertFalse( validate( mappings[2] ) )
         self.fail( "Did not raise exception" )
     except Invalid_Mapping as ex:
         self.assertEqual( "bad columns: ('vid', 'bus') not in ['Invalid', 'Column', 'Names']", ex.message )