def test_add_ship_with_nonzero_id(app): ship = Ship(id=20, affiliation="", category="", crew=0, length=0, manufacturer="", model="", ship_class="", roles=[]) assert db.add_ship(ship) == None
def create_ship(): try: ship = ship_schema.loads(request.data) except ValidationError as err: return error_response(400, err.messages) ship = db.add_ship(ship) if ship is None: return error_response(400) response = jsonify(ship_schema.dump(ship)) response.status_code = 201 response.headers["Location"] = url_for("api.get_ship", id=ship.id) return response
def test_add_ship(app): ship = Ship(id=0, affiliation="", category="", crew=0, length=0, manufacturer="", model="", ship_class="", roles=[]) ship = db.add_ship(ship) assert ship.id > 0
def test_delete_ship(app): old_len = len(db.all_ships()) ship = Ship(id=0, affiliation="?", category="?", crew=1, length=1, manufacturer="?", model="?", ship_class="?", roles=["?"]) ship = db.add_ship(ship) assert ship.id > 0 assert db.delete_ship(ship.id) assert db.get_ship(ship.id) == None assert len(db.all_ships()) == old_len
def test_add_ship_with_none_argument(app): assert db.add_ship(None) == None