示例#1
0
 def test_router_delete_attr(db_session):
     """Test deleting an identified resource attr works."""
     query_params = {}
     router = ModelResourceRouter(session=db_session, context={})
     result = router.delete("/customer/1/address",
                            query_params=query_params)
     assert result is None
示例#2
0
 def test_router_delete_subresource_child(db_session):
     """Test deleting a child subresource works."""
     query_params = {}
     router = ModelResourceRouter(session=db_session, context={})
     result = router.delete("/tracks/1/genre", query_params=query_params)
     assert result is None
     track = db_session.query(Track).filter(Track.track_id == 1).first()
     assert track.genre is None
示例#3
0
 def test_router_delete_subresource_list(db_session):
     """Test deleting a subresource list works."""
     query_params = {}
     router = ModelResourceRouter(session=db_session, context={})
     result = router.delete("albums/1/tracks", query_params=query_params)
     assert result is None
     album = db_session.query(Album).filter(Album.album_id == 1).first()
     assert len(album.tracks) == 0
示例#4
0
 def test_router_delete_collection_filtered(db_session):
     """Test deleting a resource collection works with filters."""
     query_params = {"track_id": "5"}
     router = ModelResourceRouter(session=db_session, context={})
     result = router.delete("/tracks", query_params=query_params)
     assert result is None
     track = db_session.query(Track).filter(Track.track_id == 5).first()
     assert track is None
     track = db_session.query(Track).filter(Track.track_id == 1).first()
     assert track is not None
示例#5
0
 def test_router_delete(db_session):
     """Test deleting an identified resource works."""
     query_params = {}
     router = ModelResourceRouter(session=db_session, context={})
     result = router.delete("/tracks/5", query_params=query_params)
     assert result is None
     track = db_session.query(Track).filter(Track.track_id == 5).first()
     assert track is None
     track = db_session.query(Track).filter(Track.track_id == 1).first()
     assert track is not None
示例#6
0
 def test_router_delete_collection(db_session):
     """Test deleting a resource collection works."""
     query_params = {}
     router = ModelResourceRouter(session=db_session, context={})
     result = router.delete("/invoices", query_params=query_params)
     assert result is None
示例#7
0
 def test_router_delete_attr_not_found(db_session):
     """Test deleting an unfindable identified resource attr fails."""
     query_params = {}
     router = ModelResourceRouter(session=db_session, context={})
     with raises(ResourceNotFoundError):
         router.delete("/album/1/test", query_params=query_params)
示例#8
0
 def test_router_delete_attr_unprocessable(db_session):
     """Test deleting a non null identified resource attr fails."""
     query_params = {}
     router = ModelResourceRouter(session=db_session, context={})
     with raises(UnprocessableEntityError):
         router.delete("/album/1/title", query_params=query_params)