adewes / blitzdb

Blitz is a document-oriented database for Python that is backend-agnostic. It comes with a flat-file database for JSON documents and provides MongoDB-like querying capabilities.
http://blitzdb.readthedocs.org
MIT License
330 stars 37 forks source link

As promised, here is the failed test #31

Open matrixise opened 10 years ago

matrixise commented 10 years ago

Hi Andreas,

When I execute the tests with py.test, here is the output.

platform darwin -- Python 2.7.8 -- py-1.4.25 -- pytest-2.6.3
collected 165 items

blitzdb/tests/test_autoload.py ..
blitzdb/tests/test_dbref_includes.py ....
blitzdb/tests/test_documents.py .....
blitzdb/tests/test_exceptions.py ..
blitzdb/tests/test_file_stores.py .
blitzdb/tests/test_hooks.py ........
blitzdb/tests/test_query_operators.py ...................................F............
blitzdb/tests/test_querying.py ....................................................................
blitzdb/tests/test_sorting.py ....
blitzdb/tests/test_transactions.py ................
blitzdb/tests/test_update.py .......

=============================================================================== FAILURES ===============================================================================
____________________________________________________________________________ test_ne[mongo] ____________________________________________________________________________

backend = <blitzdb.backends.mongo.backend.Backend object at 0x10276cc90>

    def test_ne(backend):
        # DB setup
        backend.filter(Actor, {}).delete()

        marlon_brando = Actor({'name': 'Marlon Brando', 'gross_income_m': 1.453, 'appearances': 78, 'is_funny': False, 'birth_year': 1924})
        leonardo_di_caprio = Actor({'name': 'Leonardo di Caprio', 'gross_income_m': 12.453, 'appearances': 34, 'is_funny': 'it depends', 'birth_year': 1974})
        david_hasselhoff = Actor({'name': 'David Hasselhoff', 'gross_income_m': 12.453, 'appearances': 173, 'is_funny': True, 'birth_year': 1952})
        charlie_chaplin = Actor({'name': 'Charlie Chaplin', 'gross_income_m': 0.371, 'appearances': 473, 'is_funny': True, 'birth_year': 1889})

        backend.save(marlon_brando)
        backend.save(leonardo_di_caprio)
        backend.save(david_hasselhoff)
        backend.save(charlie_chaplin)

        backend.commit()
        assert len(backend.filter(Actor, {})) == 4
        # DB setup

        # Test with normal conditions
        query = {'name': {'$ne': charlie_chaplin.name}}
        assert len(backend.filter(Actor, query)) == len([marlon_brando, leonardo_di_caprio, david_hasselhoff])
        # Test with normal conditions

        # Test with empty list
        query = {'name': {'$ne': []}}
        assert len(backend.filter(Actor, query)) == len([marlon_brando, charlie_chaplin, leonardo_di_caprio, david_hasselhoff])
        # Test with empty list

        # Test with list
        query = {'name': {'$ne': [marlon_brando.name, charlie_chaplin.name]}}
>       assert len(backend.filter(Actor, query)) == len([leonardo_di_caprio, david_hasselhoff, charlie_chaplin, marlon_brando])
E       assert 3 == 4
E        +  where 3 = len(<blitzdb.backends.mongo.queryset.QuerySet object at 0x102767210>)
E        +    where <blitzdb.backends.mongo.queryset.QuerySet object at 0x102767210> = <bound method Backend.filter of <blitzdb.backends.mongo.backend.Backend object at 0x10276cc90>>(Actor, {'name': {'$ne': ['Marlon Brando', 'Charlie Chaplin']}})
E        +      where <bound method Backend.filter of <blitzdb.backends.mongo.backend.Backend object at 0x10276cc90>> = <blitzdb.backends.mongo.backend.Backend object at 0x10276cc90>.filter
E        +  and   4 = len([Actor({'is_funny': 'it depends', 'gross_income_m': 12.453, 'name': 'Leonardo d...ppearances': 34, 'pk': '1f686fd660f4..._m': 1.453, 'name': 'Marlon Brando', 'appearances': 78, 'pk': '2b17c74f124a457dbb737919e1cff55e', 'birth_year': 1924})])

blitzdb/tests/test_query_operators.py:513: AssertionError
================================================================ 1 failed, 164 passed in 21.30 seconds =================================================================
dmytrokyrychuk commented 10 years ago

The following line

        assert len(backend.filter(Actor, query)) == len([leonardo_di_caprio, david_hasselhoff, charlie_chaplin, marlon_brando])

must be changed to this:

        assert len(backend.filter(Actor, query)) == len([leonardo_di_caprio, david_hasselhoff])