コード例 #1
0
def test_hole_apply_w_bad_hole(reset_db, seed_course, seed_hole):
    """
    GIVEN 1 hole instance in the database
    WHEN the apply method is called with random uuid
    THEN it should return 0 hole and update 0 hole instance in the database and ManualException with code 404
    """
    try:
        _ = hole_service.apply(instance=generate_uuid(), name='Ringo')
    except ManualException as ex:
        assert ex.code == 400
コード例 #2
0
ファイル: test_sport.py プロジェクト: dallanb/sport
def test_sport_find_by_non_existent_column():
    """
    GIVEN 2 sport instance in the database
    WHEN the find method is called with a random column
    THEN it should return the 0 sport and ManualException with code 400
    """
    try:
        _ = sport_service.find(junk=generate_uuid())
    except ManualException as ex:
        assert ex.code == 400
コード例 #3
0
ファイル: test_course.py プロジェクト: dallanb/course
def test_course_update_w_bad_uuid(reset_db, seed_course):
    """
    GIVEN 1 course instance in the database
    WHEN the update method is called with random uuid
    THEN it should return 0 course and update 0 course instance into the database and ManualException with code 404
    """
    try:
        _ = course_service.update(uuid=generate_uuid(), name='Ringo')
    except ManualException as ex:
        assert ex.code == 404
コード例 #4
0
ファイル: test_sport.py プロジェクト: dallanb/sport
def test_sport_create_w_non_existent_name(pause_notification):
    """
    GIVEN 1 sport instance in the database
    WHEN the create method is called with non existent sport_name uuid
    THEN it should return 0 sport and add 0 sport instance into the database and ManualException with code 500
    """

    try:
        _ = sport_service.create(name=generate_uuid())
    except ManualException as ex:
        assert ex.code == 500
コード例 #5
0
def test_hole_add_w_non_existent_course_uuid(reset_db):
    """
    GIVEN 1 hole instance in the database
    WHEN the add method is called with non existent course uuid
    THEN it should return 1 hole and add 0 hole instance into the database
    """
    course_uuid = generate_uuid()
    hole = hole_service.add(course_uuid=course_uuid, name=pytest.hole_name, number=pytest.hole_number, par=pytest.par,
                            distance=pytest.distance)
    assert hole.course_uuid == course_uuid
    hole_service._rollback()
コード例 #6
0
ファイル: test_db.py プロジェクト: dallanb/sport
def test_find():
    """
    GIVEN a db instance
    WHEN calling the find method of the db instance
    THEN it should find a sport instance from the database
    """
    result = db.find(model=Sport)
    assert result.total == 2
    assert len(result.items) == 2

    result = db.find(model=Sport, uuid=generate_uuid())
    assert result.total == 0
コード例 #7
0
def test_find():
    """
    GIVEN a db instance
    WHEN calling the find method of the db instance
    THEN it should find a course instance from the database
    """
    result = db.find(model=Course)
    assert result.total == 1
    assert len(result.items) == 1

    result = db.find(model=Course, uuid=generate_uuid())
    assert result.total == 0