def test_show_available_products(mongo_database):
    ''' available products '''
    l.import_data(mongo_database, '', 'product.csv', 'customer.csv', 'rental.csv')
    students_response = l.show_available_products(mongo_database)
    assert len(students_response) == 9999
    assert 'P000001' in students_response
    assert 'P010999' not in students_response
def test_show_rentals(_show_rentals, mongo_database):
    ''' rentals '''
    l.import_data(mongo_database, '', 'product.csv', 'customer.csv',
                  'rental.csv')
    students_response = l.show_rentals(mongo_database, 'prd002')
    expected = {
        'C000002': {
            'first_name': 'Blanca',
            'last_name': 'Bashirian',
            'address': '0193 Malvina Lake',
            'phone_number': '(240)014-9496 x08349',
            'email': '*****@*****.**',
            'status': 'Active',
            'credit_limit': '689'
        },
        'C000004': {
            'first_name': 'Mittie',
            'last_name': 'Turner',
            'address': '996 Lorenza Points',
            'phone_number': '1-324-023-8861 x025',
            'email': '*****@*****.**',
            'status': 'Active',
            'credit_limit': '565'
        }
    }

    assert len(students_response) == 2
    assert list(students_response.keys()) == ["C000002", "C000004"]
    assert students_response == expected
def test_clear_data(mongo_database):
    '''
    Testing database clearing.
    '''
    l.import_data(mongo_database, '', 'product.csv', 'customer.csv', 'rental.csv')

    result = mongo_database.list_collection_names()
    assert result == ['products', 'rentals', 'customers']

    l.clear_data(mongo_database)
    result2 = mongo_database.list_collection_names()
    assert result2 == []
def test_show_rentals(mongo_database):
    l.import_data(mongo_database, '', 'product.csv', 'customer.csv', 'rental.csv')
    result = l.show_rentals(mongo_database, 'P000004')

    assert len(result) == 2
    assert list(result.keys()) == ['C000002', 'C000004']
def test_import_data(mongo_database):
    ''' import '''
    result = l.import_data(mongo_database, '', 'product.csv', 'customer.csv', 'rental.csv')

    assert result == ((9999, 9999, 9999), (0, 0, 0))