示例#1
0
def ship():
    """A dummy ship fixture."""

    ship = Ship(imo=9595321, name='MSC Preziosa')
    ship.save()

    return ship
def test_update_non_existing_ship(app):
    ship = Ship(id=99,
                affiliation="?",
                category="?",
                crew=1,
                length=1,
                manufacturer="?",
                model="?",
                ship_class="?",
                roles=["?"])
    assert db.update_ship(ship) == False
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 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_update_ship_with_bad_id(app):
    ship1 = Ship(id=0,
                 affiliation="?",
                 category="?",
                 crew=1,
                 length=1,
                 manufacturer="?",
                 model="?",
                 ship_class="?",
                 roles=["?"])
    ship2 = Ship(id=-1,
                 affiliation="?",
                 category="?",
                 crew=1,
                 length=1,
                 manufacturer="?",
                 model="?",
                 ship_class="?",
                 roles=["?"])
    assert db.update_ship(ship1) == False
    assert db.update_ship(ship2) == False
def test_get_next_ship_id_from_populated_list(app):
    ships = [
        Ship(id=3,
             affiliation="",
             category="",
             crew=0,
             length=0,
             manufacturer="",
             model="",
             ship_class="",
             roles=[]),
        Ship(id=7,
             affiliation="",
             category="",
             crew=0,
             length=0,
             manufacturer="",
             model="",
             ship_class="",
             roles=[]),
    ]
    assert db.get_next_ship_id(ships) == 8
def test_update_ship(app):
    ship1 = Ship(id=5,
                 affiliation="?",
                 category="?",
                 crew=1,
                 length=1,
                 manufacturer="?",
                 model="?",
                 ship_class="?",
                 roles=["?"])
    assert db.update_ship(ship1)
    ship2 = db.get_ship(5)
    assert ship1.id == ship2.id
    assert ship1.model == ship2.model
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
示例#9
0
    man4 = Manufacturer(id=4, name='Cybertronian Technologies')
    man5 = Manufacturer(id=5, name='Weyland-Yutani Corporation')
    cat1 = Category(id=1, name='Military')
    cat2 = Category(id=2, name='Transport')
    cat3 = Category(id=3, name='Cargo')
    cat4 = Category(id=4, name='Performance')
    cat5 = Category(id=5, name='Luxury')

    ship1 = Ship(
        name='Frontier',
        manufacturer_id=5,
        category_id=1,
        size=8473,
        designer='T\'Maha',
        crew_cap=2500,
        travel_range=15600,
        ftl=True,
        used=False,
        model_link='/spaceships/ship1_green.glb',
        description=
        "Nicknamed \"The Military's Ostrich,\" this ship has what every general is the Celestial Armed Forces could want: 2 big cannons mounted directly to the front. Needless to say, when it comes to rear attacks, this ship has it's head in the sand.",
        stock=3,
        total_sold=0,
        price=470000)
    ship2 = Ship(
        name='SS Dreadnought',
        manufacturer_id=4,
        category_id=2,
        size=4788,
        designer='Glama V\'Leeni',
        crew_cap=1000,
        travel_range=9500,