Ticket:user Management

(mflix) Chandras-MBP:tests chandradesam$ pytest -m user_management

============================= test session starts ==============================
platform darwin – Python 3.7.6, pytest-5.3.2, py-1.8.1, pluggy-0.13.1
rootdir: /Users/chandradesam/sujji/mflix-python/tests
plugins: flask-0.10.0, astropy-header-0.1.1, arraydiff-0.3, remotedata-0.3.2, openfiles-0.4.0, doctestplus-0.5.0, hypothesis-4.54.2
collected 43 items / 39 deselected / 4 selected

test_user_management.py EEEE [100%]

==================================== ERRORS ====================================
_____________________ ERROR at setup of test_registration ______________________

request = <SubRequest ‘_configure_application’ for >
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x11688cbd0>

@pytest.fixture(autouse=True)
def _configure_application(request, monkeypatch):
    """Use `pytest.mark.options` decorator to pass options to your application
    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 AttributeError: ‘SubRequest’ object has no attribute ‘getfuncargvalue’

…/…/…/.local/lib/python3.7/site-packages/pytest_flask/plugin.py:109: AttributeError
______________ ERROR at setup of test_no_duplicate_registrations _______________

request = <SubRequest ‘_configure_application’ for >
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x1168a4910>

@pytest.fixture(autouse=True)
def _configure_application(request, monkeypatch):
    """Use `pytest.mark.options` decorator to pass options to your application
    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 AttributeError: ‘SubRequest’ object has no attribute ‘getfuncargvalue’

…/…/…/.local/lib/python3.7/site-packages/pytest_flask/plugin.py:109: AttributeError
_________________________ ERROR at setup of test_login _________________________

request = <SubRequest ‘_configure_application’ for >
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x1168a43d0>

@pytest.fixture(autouse=True)
def _configure_application(request, monkeypatch):
    """Use `pytest.mark.options` decorator to pass options to your application
    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 AttributeError: ‘SubRequest’ object has no attribute ‘getfuncargvalue’

…/…/…/.local/lib/python3.7/site-packages/pytest_flask/plugin.py:109: AttributeError
________________________ ERROR at setup of test_logout _________________________

request = <SubRequest ‘_configure_application’ for >
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x11685f0d0>

@pytest.fixture(autouse=True)
def _configure_application(request, monkeypatch):
    """Use `pytest.mark.options` decorator to pass options to your application
    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 AttributeError: ‘SubRequest’ object has no attribute ‘getfuncargvalue’

…/…/…/.local/lib/python3.7/site-packages/pytest_flask/plugin.py:109: AttributeError

iam getting above error,when running pytest -m user_management

Can you try running the test command from mflix directory? where you have your .ini file and not the tests directory.

Kanika

(base) Chandras-MBP:sujji chandradesam$ cd mflix-python

(base) Chandras-MBP:mflix-python chandradesam$ conda activate mflix

(mflix) Chandras-MBP:mflix-python chandradesam$ pytest -m user_management

============================= test session starts ==============================
platform darwin – Python 3.7.6, pytest-5.3.2, py-1.8.1, pluggy-0.13.1
rootdir: /Users/chandradesam/sujji/mflix-python
plugins: flask-0.10.0, astropy-header-0.1.1, arraydiff-0.3, remotedata-0.3.2, openfiles-0.4.0, doctestplus-0.5.0, hypothesis-4.54.2
collected 43 items / 39 deselected / 4 selected

tests/test_user_management.py EEEE [100%]

==================================== ERRORS ====================================
_____________________ ERROR at setup of test_registration ______________________

request = <SubRequest ‘_configure_application’ for >
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x117f0c5d0>

@pytest.fixture(autouse=True)
def _configure_application(request, monkeypatch):
    """Use `pytest.mark.options` decorator to pass options to your application
    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 AttributeError: ‘SubRequest’ object has no attribute ‘getfuncargvalue’

…/…/.local/lib/python3.7/site-packages/pytest_flask/plugin.py:109: AttributeError
______________ ERROR at setup of test_no_duplicate_registrations _______________

request = <SubRequest ‘_configure_application’ for >
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x117f515d0>

@pytest.fixture(autouse=True)
def _configure_application(request, monkeypatch):
    """Use `pytest.mark.options` decorator to pass options to your application
    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 AttributeError: ‘SubRequest’ object has no attribute ‘getfuncargvalue’

…/…/.local/lib/python3.7/site-packages/pytest_flask/plugin.py:109: AttributeError
_________________________ ERROR at setup of test_login _________________________

request = <SubRequest ‘_configure_application’ for >
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x117ee77d0>

@pytest.fixture(autouse=True)
def _configure_application(request, monkeypatch):
    """Use `pytest.mark.options` decorator to pass options to your application
    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 AttributeError: ‘SubRequest’ object has no attribute ‘getfuncargvalue’

…/…/.local/lib/python3.7/site-packages/pytest_flask/plugin.py:109: AttributeError
________________________ ERROR at setup of test_logout _________________________

request = <SubRequest ‘_configure_application’ for >
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x117ef3710>

@pytest.fixture(autouse=True)
def _configure_application(request, monkeypatch):
    """Use `pytest.mark.options` decorator to pass options to your application
    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 AttributeError: ‘SubRequest’ object has no attribute ‘getfuncargvalue’

…/…/.local/lib/python3.7/site-packages/pytest_flask/plugin.py:109: AttributeError

I ran test command from mflix-python directory,but iam getting above error

Hi @SUJANA_42894,

Try the following solution:

If that does not work, try running pip install -r requirements.txt again and let me know if that helps.

Kanika

That error gone.Now iam getting error in python run.py i.e KeyError:‘MFLIX_NS’

(mflix) Chandras-MBP:mflix-python chandradesam$ python run.py

  • Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
  • Restarting with stat
  • Debugger is active!
  • Debugger PIN: 106-539-899
    127.0.0.1 - - [17/Jan/2020 22:58:38] “GET / HTTP/1.1” 200 -
    127.0.0.1 - - [17/Jan/2020 22:58:39] “GET /api/v1/movies/ HTTP/1.1” 500 -
    Traceback (most recent call last):
    File “/Users/chandradesam/sujji/mflix-python/anaconda3/envs/mflix/lib/python3.7/site-packages/flask/app.py”, line 1997, in call
    return self.wsgi_app(environ, start_response)
    File “/Users/chandradesam/sujji/mflix-python/anaconda3/envs/mflix/lib/python3.7/site-packages/flask/app.py”, line 1985, in wsgi_app
    response = self.handle_exception(e)
    File “/Users/chandradesam/.local/lib/python3.7/site-packages/flask_cors/extension.py”, line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
    File “/Users/chandradesam/sujji/mflix-python/anaconda3/envs/mflix/lib/python3.7/site-packages/flask/app.py”, line 1540, in handle_exception
    reraise(exc_type, exc_value, tb)
    File “/Users/chandradesam/sujji/mflix-python/anaconda3/envs/mflix/lib/python3.7/site-packages/flask/_compat.py”, line 33, in reraise
    raise value
    File “/Users/chandradesam/sujji/mflix-python/anaconda3/envs/mflix/lib/python3.7/site-packages/flask/app.py”, line 1982, in wsgi_app
    response = self.full_dispatch_request()
    File “/Users/chandradesam/sujji/mflix-python/anaconda3/envs/mflix/lib/python3.7/site-packages/flask/app.py”, line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
    File “/Users/chandradesam/.local/lib/python3.7/site-packages/flask_cors/extension.py”, line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
    File “/Users/chandradesam/sujji/mflix-python/anaconda3/envs/mflix/lib/python3.7/site-packages/flask/app.py”, line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
    File “/Users/chandradesam/sujji/mflix-python/anaconda3/envs/mflix/lib/python3.7/site-packages/flask/_compat.py”, line 33, in reraise
    raise value
    File “/Users/chandradesam/sujji/mflix-python/anaconda3/envs/mflix/lib/python3.7/site-packages/flask/app.py”, line 1612, in full_dispatch_request
    rv = self.dispatch_request()
    File “/Users/chandradesam/sujji/mflix-python/anaconda3/envs/mflix/lib/python3.7/site-packages/flask/app.py”, line 1598, in dispatch_request
    return self.view_functionsrule.endpoint
    File “/Users/chandradesam/sujji/mflix-python/mflix/api/movies.py”, line 26, in api_get_movies
    None, page=0, movies_per_page=MOVIES_PER_PAGE)
    File “/Users/chandradesam/sujji/mflix-python/mflix/db.py”, line 228, in get_movies
    cursor = db.movies.find(query).sort(sort)
    File “/Users/chandradesam/sujji/mflix-python/anaconda3/envs/mflix/lib/python3.7/site-packages/werkzeug/local.py”, line 348, in getattr
    return getattr(self._get_current_object(), name)
    File “/Users/chandradesam/sujji/mflix-python/anaconda3/envs/mflix/lib/python3.7/site-packages/werkzeug/local.py”, line 307, in _get_current_object
    return self.__local()
    File “/Users/chandradesam/sujji/mflix-python/mflix/db.py”, line 28, in get_db
    MFLIX_DB_NAME = current_app.config[“MFLIX_NS”]
    *KeyError: ‘MFLIX_NS’

127.0.0.1 - - [17/Jan/2020 22:58:39] “GET /api/v1/movies/facet-search?cast=Denzel%20Washington&page=0 HTTP/1.1” 400 -
127.0.0.1 - - [17/Jan/2020 22:58:40] “GET /manifest.json HTTP/1.1” 200 -

Make sure dotini file has been renamed to just “.ini”.

If you are still getting error, please share the contents of the file here.

Kanika

I replaced dotini file with .ini.But also iam getting same error.

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-ant7a.mongodb.net

MFLIX_NS = sample_mflix

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

MFLIX_NS = sample_mflix

Hi @SUJANA_42894,

Thanks for sharing the information. I see that you have passed the ticket, let me know if you still have any queries. :slight_smile:

Kanika

iam still getting keyerror:MFLIX_NS when iam running python run.py

Okay thanks for letting us know. I can see you have passed the tests, just wanted to know is the STATUS page working for you?

Also, if it is not, you can email me the zip directory of mflix-python: kanika.singla@mongodb.com We can debug it further :slight_smile:

Kanika