Example #1
0
def test_unknown_from_db_then_cache():
    styles = StyleDB()
    styles.cache = StyleCache('tests/sample_csv_files/beer_and_style.csv')
    styles.brew_db = mock_brewery_db.MockDB()
    assert styles.get_style('Duck Tails') == 'Unknown'
    assert styles.get_style('Duck Tails') == 'Unknown'
    assert styles.brew_db.count == 0
Example #2
0
def test_two_against_db():
    styles = StyleDB()
    styles.cache = StyleCache('tests/sample_csv_files/beer_and_style.csv')
    styles.brew_db = mock_brewery_db.MockDB()
    assert styles.get_style('xyz') == "Unknown"
    assert styles.get_style('xyz') == "Unknown"
    assert styles.brew_db.count == 2
Example #3
0
def test_db_has_style_and_then_cache():
    styles = StyleDB()
    styles.cache = StyleCache('tests/sample_csv_files/beer_and_style.csv')
    styles.brew_db = mock_brewery_db.MockDB()
    assert styles.get_style('Guinness') == 'Stout'
    assert styles.get_style('Guinness') == 'Stout'
    assert styles.brew_db.count == 0
Example #4
0
def test_db_has_style_and_then_cache():
    styles = StyleDB()
    tested = styles.get_style('Guinness')
    print(tested)
    assert styles.get_style('Guinness') == 'stout'
    assert styles.get_style('Guinness') == 'stout'
    assert styles.brew_db.count == 1
Example #5
0
def initialize_inventory():
    location = FileLocation.save_location
    the_file = most_recent_file.MostRecentFile(location)
    style = StyleDB()
    inventory = Inventory(the_file, style)
    global QUERIES
    QUERIES = InventoryQueries(inventory)
Example #6
0
def test_cache_has_beer():
    styles = StyleDB()
    styles.cache = StyleCache('tests/sample_csv_files/beer_and_style.csv')
    styles.brew_db = mock_brewery_db.MockDB()
    assert styles.get_style('Nitro') == 'Stout'
    assert styles.brew_db.count == 0
Example #7
0
def test_cache_has_beer():
    styles = StyleDB()
    assert styles.get_style('Nitro') == 'stout'
    assert styles.brew_db.count == 0
Example #8
0
def test_two_against_db():
    """ Tests that if query throws error once, that it throws it again by same input """
    styles = StyleDB()
    assert styles.get_style('xyz') == "Unknown"
    assert styles.get_style('xyz') == "Unknown"
    assert styles.brew_db.count == 2
Example #9
0
def test_unknown_from_db_then_cache():
    styles = StyleDB()
    assert styles.get_style('Duck Tails') == 'Unknown'
    assert styles.get_style('Duck Tails') == 'Unknown'
    assert styles.brew_db.count == 1