Projection error

While running projection test getting the below error. Any idea?

C:\Users\LEN X220-2\Downloads\mflix-python>pytest -m projection
============================= test session starts =============================
platform win32 – Python 3.7.1, pytest-4.0.2, py-1.7.0, pluggy-0.8.0
rootdir: C:\Users\LEN X220-2\Downloads\mflix-python, inifile:
plugins: remotedata-0.3.1, openfiles-0.3.1, flask-0.10.0, doctestplus-0.2.0, arr
aydiff-0.3
collected 43 items / 41 deselected

tests\test_projection.py EE [100%]

=================================== ERRORS ====================================
_______________ ERROR at setup of test_basic_country_search_db ________________

request = <SubRequest ‘_configure_application’ for <Function ‘test_basic_country
_search_db’>>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x0000000005413F28>

@pytest.fixture(autouse=True)
def _configure_application(request, monkeypatch):
    """Use `pytest.mark.options` decorator to pass options to your applicati

on
factory::

        @pytest.mark.options(debug=False)
        def test_something(app):
            assert not app.debug, 'the application works not in debug mode!'


    """
    if 'app' not in request.fixturenames:
        return
  app = request.getfuncargvalue('app')

E _pytest.warning_types.RemovedInPytest4Warning: getfuncargvalue is deprec
ated, use getfixturevalue

C:\Govind\Anaconda3\lib\site-packages\pytest_flask\plugin.py:109: RemovedInPytes
t4Warning
____________ ERROR at setup of test_basic_country_search_shape_db _____________

request = <SubRequest ‘_configure_application’ for <Function ‘test_basic_country
_search_shape_db’>>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x000000000546AD30>

@pytest.fixture(autouse=True)
def _configure_application(request, monkeypatch):
    """Use `pytest.mark.options` decorator to pass options to your applicati

on
factory::

        @pytest.mark.options(debug=False)
        def test_something(app):
            assert not app.debug, 'the application works not in debug mode!'


    """
    if 'app' not in request.fixturenames:
        return
  app = request.getfuncargvalue('app')

C:\Govind\Anaconda3\lib\site-packages\pytest_flask\plugin.py:109:


request = <SubRequest ‘_configure_application’ for <Function ‘test_basic_country
_search_db’>>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x0000000005413F28>

@pytest.fixture(autouse=True)
def _configure_application(request, monkeypatch):
    """Use `pytest.mark.options` decorator to pass options to your applicati

on
factory::

        @pytest.mark.options(debug=False)
        def test_something(app):
            assert not app.debug, 'the application works not in debug mode!'


    """
    if 'app' not in request.fixturenames:
        return
  app = request.getfuncargvalue('app')

E _pytest.warning_types.RemovedInPytest4Warning: getfuncargvalue is deprec
ated, use getfixturevalue

C:\Govind\Anaconda3\lib\site-packages\pytest_flask\plugin.py:109: RemovedInPytes
t4Warning
=================== 41 deselected, 2 error in 0.29 seconds ====================

C:\Users\LEN X220-2\Downloads\mflix-python>

you have to open C:\Govind\Anaconda3\lib\site-packages\pytest_flask\plugin.py and replace getfuncargvalue with getfixturevalue

Hi,

I am getting this error now.

C:\Users\LEN X220-2\Downloads\mflix-python>pytest -m projection
============================= test session starts =============================
platform win32 – Python 3.7.1, pytest-4.0.2, py-1.7.0, pluggy-0.8.0
rootdir: C:\Users\LEN X220-2\Downloads\mflix-python, inifile:
plugins: remotedata-0.3.1, openfiles-0.3.1, flask-0.10.0, doctestplus-0.2.0, arr
aydiff-0.3
collected 43 items / 41 deselected

tests\test_projection.py FF [100%]

================================== FAILURES ===================================
________________________ test_basic_country_search_db _________________________

client = <FlaskClient <Flask ‘mflix.factory’>>

@pytest.mark.projection
def test_basic_country_search_db(client):
    countries = ['Kosovo']
    result = get_movies_by_country(countries)
  assert len(result) == 2

E TypeError: object of type ‘ConfigurationError’ has no len()

tests\test_projection.py:15: TypeError
_____________________ test_basic_country_search_shape_db ______________________

client = <FlaskClient <Flask ‘mflix.factory’>>

@pytest.mark.projection
def test_basic_country_search_shape_db(client):
    countries = ['Russia', 'Japan']
    result = get_movies_by_country(countries)
  assert len(result) == 2421

E TypeError: object of type ‘ConfigurationError’ has no len()

tests\test_projection.py:22: TypeError
=================== 2 failed, 41 deselected in 0.53 seconds ===================

C:\Users\LEN X220-2\Downloads\mflix-python>

Can anyone help? i’m just trying to find out how it is working. so that it wont interrupt further in the course.

Did you try your projection in mongo shell?

Can you share the content of .ini?

you mean to execute the query? yes it worked

couldnt locate this .ini file. where will this be?

Ticket: Connection

Rename this file to .ini after filling in your MFLIX_DB_URI and your SECRET_KEY

Do not surround the URI with quotes

[PROD]
SECRET_KEY = super_secret_key_you_should_change
MFLIX_DB_URI = mongodb+srv://m220student:m220password@mflix-yhnlx.mongodb.net

[TEST]
SECRET_KEY = super_secret_testing_key
MFLIX_DB_URI = mongodb+srv://m220student:m220password@mflix-yhnlx.mongodb.net

Could you try again now that the .ini file is correct?

Getting the same error again.

Send me your file db.py with https://www.dropbox.com/request/4KuurQ8b4JsQ9FatlReR and I will take a look.

i have sent the file

I don’t think your find in get_movies_by_country really work in the shell.

The variable countries received by the function is a list. For example, countries = [‘Russia’, ‘Japan’] like shown in the error you get. In addition, you refer to $countries which is not appropriate in the context of find(). But the later should not cause any error as it is in quote so it interpreted as a string.

Tried with the later code as well. got the same error. that is running perfectly in the compass shell as well
{“countries”:{"$in": [‘Kosovo’]}}

C:\Users\LEN X220-2\Downloads\mflix-python>pytest -m projection
============================= test session starts =============================
platform win32 – Python 3.7.1, pytest-4.0.2, py-1.7.0, pluggy-0.8.0
rootdir: C:\Users\LEN X220-2\Downloads\mflix-python, inifile:
plugins: remotedata-0.3.1, openfiles-0.3.1, flask-0.10.0, doctestplus-0.2.0, arr
aydiff-0.3
collected 43 items / 41 deselected

tests\test_projection.py FF [100%]

================================== FAILURES ===================================
________________________ test_basic_country_search_db _________________________

client = <FlaskClient <Flask ‘mflix.factory’>>

@pytest.mark.projection
def test_basic_country_search_db(client):
    countries = ['Kosovo']
    result = get_movies_by_country(countries)
  assert len(result) == 2

E TypeError: object of type ‘ConfigurationError’ has no len()

tests\test_projection.py:15: TypeError
_____________________ test_basic_country_search_shape_db ______________________

client = <FlaskClient <Flask ‘mflix.factory’>>

@pytest.mark.projection
def test_basic_country_search_shape_db(client):
    countries = ['Russia', 'Japan']
    result = get_movies_by_country(countries)
  assert len(result) == 2421

E TypeError: object of type ‘ConfigurationError’ has no len()

tests\test_projection.py:22: TypeError
=================== 2 failed, 41 deselected in 0.77 seconds ===================

i’m getting this error. couldnt proceed further. can anyone help? is it problem with other python code?

C:\Users\LEN X220-2\Downloads\mflix-python>pytest -m projection
============================= test session starts =============================
platform win32 – Python 3.7.1, pytest-4.0.2, py-1.7.0, pluggy-0.8.0
rootdir: C:\Users\LEN X220-2\Downloads\mflix-python, inifile:
plugins: remotedata-0.3.1, openfiles-0.3.1, flask-0.10.0, doctestplus-0.2.0, arr
aydiff-0.3
collected 43 items / 41 deselected

tests\test_projection.py FF [100%]

================================== FAILURES ===================================
________________________ test_basic_country_search_db _________________________

client = <FlaskClient <Flask ‘mflix.factory’>>

@pytest.mark.projection
def test_basic_country_search_db(client):
    countries = ['Kosovo']
    result = get_movies_by_country(countries)
  assert len((result)) == 2

E TypeError: object of type ‘ConfigurationError’ has no len()

tests\test_projection.py:16: TypeError
_____________________ test_basic_country_search_shape_db ______________________

client = <FlaskClient <Flask ‘mflix.factory’>>

@pytest.mark.projection
def test_basic_country_search_shape_db(client):
    countries = ['Russia', 'Japan']
    result = get_movies_by_country(countries)
  assert len(result) == 2421

E TypeError: object of type ‘ConfigurationError’ has no len()

tests\test_projection.py:23: TypeError
=================== 2 failed, 41 deselected in 0.45 seconds ===================

C:\Users\LEN X220-2\Downloads\mflix-python>

I have look at the test code, the api, … and no where I see anything related to ConfigurationError so I suspect thant something when wrong when install packages from requirements.txt. I would redo it from scratch.

1 Like

@mjshaheed, sorry but it is not the same error. Same location but different. You have TYpeError: object of type ‘TypeError’ has no len().

@Govindaraj_24121, has TypeError: object of type ‘ConfigurationError’ has no len().

It is almost the same. Your get_movies_by_country returns a TypeError while his version returns ConfigurationError. The error is detected at the same place but it does not come from the same problem.

In addition his revised query as shown in Projection error is appropriate.

Oh Yes. Thanks. Hope he ignores my suggestion. :disappointed_relieved:

Hi Steeve,

I disconnected my Internet and tried to run it again. I think I got same errors as Govind did.
udishten
Can you please check if it happens for you as well?

Thanks,
Shahul