Example #1
0
def test_availability_filter():
    saver = MockInventoryQueriesSaving()
    beerapi.queries = saver
    APP.get('/current?name=Guinness&availability=2')
    assert saver.filter.name == 'Guinness'
    assert saver.filter.availability == '2'
    assert saver.filter.style is None
Example #2
0
def test_size_filter():
    saver = MockInventoryQueriesSaving()
    beerapi.queries = saver
    APP.get('/current?name=Guinness&availability=2&style=stout&size=12/12OZ')
    assert saver.filter.name == 'Guinness'
    assert saver.filter.availability == '2'
    assert saver.filter.style == 'stout'
    assert saver.filter.size == '12/12OZ'
Example #3
0
def test_style_filter():
    saver = MockInventoryQueriesSaving()
    beerapi.QUERIES = saver
    APP.get('/current?name=Guinness&availability=2&style=stout')
    assert saver.filter.name == 'Guinness'
    assert saver.filter.availability == '2'
    assert saver.filter.style == 'stout'
    assert saver.filter.size is None
Example #4
0
def test_bad_and_good_params():
    saver = MockInventoryQueriesSaving()
    beerapi.queries = saver
    result = APP.get('/current?name=Guinness&foo=bar')
    assert result.status_code == 400
Example #5
0
def test_repeat_params():
    saver = MockInventoryQueriesSaving()
    beerapi.queries = saver
    APP.get('/current?name=Guinness&name=Pabst')
    assert saver.filter.name == 'Guinness'
Example #6
0
def test_name_filter():
    saver = MockInventoryQueriesSaving()
    beerapi.queries = saver
    APP.get('/current?name=Guinness')
    assert beerapi.queries.filter.name == 'Guinness'
    assert saver.filter.style is None
Example #7
0
def test_no_filter():
    saver = MockInventoryQueriesSaving()
    beerapi.queries = saver
    APP.get('/current')
    assert saver.filter.name is None
    assert saver.filter.style is None
Example #8
0
def test_bad_params():
    saver = MockInventoryQueriesSaving()
    beerapi.QUERIES = saver
    result = APP.get('/current?foo=bar')
    assert result.status_code == 400