def test_db_add(dbtransaction, model_test_params):
    """Test that one of each type of model can be added to the DB."""
    for model_name, params in model_test_params:
        model = globals()[model_name]
        instance = model(**params)
        DBSession.add(instance)
        DBSession.flush()
        assert DBSession.query(model).count() == 1
Beispiel #2
0
def test_db_add(dbtransaction, model_test_params):
    """Test that one of each type of model can be added to the DB."""
    for model_name, params in model_test_params:
        model = globals()[model_name]
        instance = model(**params)
        DBSession.add(instance)
        DBSession.flush()
        assert DBSession.query(model).count() == 1
def test_rov_sol_empty(dbtransaction, global_environ, rover_params, sol):
    """Test get_rov_sol return value for Rover with no cameras or photos."""
    rover = rover_params['name']
    DBSession.add(Rover(**rover_params))
    DBSession.flush()
    # expected = {'rover': rover, 'sol': sol, 'photos_by_cam': {}}
    # assert Photo.get_rov_sol(rover, sol) == expected
    with pytest.raises(ValueError):
        Photo.get_rov_sol(rover, sol)
Beispiel #4
0
def test_rov_sol_empty(dbtransaction, global_environ, rover_params, sol):
    """Test get_rov_sol return value for Rover with no cameras or photos."""
    rover = rover_params['name']
    DBSession.add(Rover(**rover_params))
    DBSession.flush()
    # expected = {'rover': rover, 'sol': sol, 'photos_by_cam': {}}
    # assert Photo.get_rov_sol(rover, sol) == expected
    with pytest.raises(ValueError):
        Photo.get_rov_sol(rover, sol)
def test_rov_sol_one_camera(dbtransaction, global_environ, rover_params,
                            camera_params, sol):
    """Test get_rov_sol return value for a Rover with one Camera."""
    rover = rover_params['name']
    # camera = '_'.join((rover, camera_params['name']))
    DBSession.add(Rover(**rover_params))
    DBSession.add(Camera(**camera_params))
    DBSession.flush()
    # expected = {'rover': rover, 'sol': sol, 'photos_by_cam': {camera: []}}
    # assert Photo.get_rov_sol(rover, sol) == expected
    with pytest.raises(ValueError):
        Photo.get_rov_sol(rover, sol)
Beispiel #6
0
def test_rov_sol_one_camera(dbtransaction, global_environ, rover_params,
                            camera_params, sol):
    """Test get_rov_sol return value for a Rover with one Camera."""
    rover = rover_params['name']
    # camera = '_'.join((rover, camera_params['name']))
    DBSession.add(Rover(**rover_params))
    DBSession.add(Camera(**camera_params))
    DBSession.flush()
    # expected = {'rover': rover, 'sol': sol, 'photos_by_cam': {camera: []}}
    # assert Photo.get_rov_sol(rover, sol) == expected
    with pytest.raises(ValueError):
        Photo.get_rov_sol(rover, sol)
def test_get_rov_sol_too_big(dbtransaction, global_environ, photo_params,
                             rover_params, camera_params):
    """Compare sol with no photos to next sol with photos. Should be equal."""
    rover = rover_params['name']
    sol = photo_params['sol']
    photo = Photo(**photo_params)
    DBSession.add(Rover(**rover_params))
    DBSession.add(Camera(**camera_params))
    DBSession.add(photo)
    DBSession.flush()
    assert Photo.get_rov_sol(rover, sol + 500) == Photo.get_rov_sol(rover, sol)
Beispiel #8
0
def test_get_rov_sol_too_big(dbtransaction, global_environ, photo_params,
                             rover_params, camera_params):
    """Compare sol with no photos to next sol with photos. Should be equal."""
    rover = rover_params['name']
    sol = photo_params['sol']
    photo = Photo(**photo_params)
    DBSession.add(Rover(**rover_params))
    DBSession.add(Camera(**camera_params))
    DBSession.add(photo)
    DBSession.flush()
    assert Photo.get_rov_sol(rover, sol + 500) == Photo.get_rov_sol(rover, sol)
def test_rov_sol_one_photo(dbtransaction, global_environ, rover_params,
                           camera_params, photo_params):
    """Test return value for get_rov_sol with one Photo."""
    rover = rover_params['name']
    sol = photo_params['sol']
    camera = '_'.join((rover, camera_params['name']))
    photo = Photo(**photo_params)
    DBSession.add(Rover(**rover_params))
    DBSession.add(Camera(**camera_params))
    DBSession.add(photo)
    DBSession.flush()
    expected = {'rover': rover, 'sol': sol,
                'photos_by_cam': {camera: [photo]},
                'last_day': True, 'first_day': False}
    assert Photo.get_rov_sol(rover, sol) == expected
Beispiel #10
0
def test_rov_sol_one_photo(dbtransaction, global_environ, rover_params,
                           camera_params, photo_params):
    """Test return value for get_rov_sol with one Photo."""
    rover = rover_params['name']
    sol = photo_params['sol']
    camera = '_'.join((rover, camera_params['name']))
    photo = Photo(**photo_params)
    DBSession.add(Rover(**rover_params))
    DBSession.add(Camera(**camera_params))
    DBSession.add(photo)
    DBSession.flush()
    expected = {
        'rover': rover,
        'sol': sol,
        'photos_by_cam': {
            camera: [photo]
        },
        'last_day': True,
        'first_day': False
    }
    assert Photo.get_rov_sol(rover, sol) == expected