Where is validation code for connection?

Help to understand, please, this picture).
Where does the validation code for connection have to be displayed?
On the place of a phrase “Currently Validating”?

result pytest -m connection
============ 4 passed, 31 deselected, 12 warnings in 3.81 seconds =============

Yes, if your code is working the connection box will turn green and display a code string and a “copy” button to allow you to paste into lab answer field.

test is passed - connection - ok,
maybe it is necessary, somewhere in a code to note that a test is passed?

Zyo,

  1. Copy the string from the green box on the http://localhost:5000/status page
  2. Return to https://university.mongodb.com/mercury/M220P/2018_October/chapter/Chapter_1_Driver_Setup/
  3. Navigate to “Ticket: Connection” in the Lessons side bar menu.
  4. Scroll down to the end of the instructions for the lab, you will see a text box with “Enter your answer here:” just above it.
  5. Paste the hex string from your successful test in the text box, then click SUBMIT button

:slight_smile:

ok,once again question ) :

  • a command a test connection is passed (pytest -m connection)
  • after application launch on the status page there is no “green_connection_box”
    what to do?

Hello zyo,

It sounds like the unit test for this homework is passing, but the integration test (the MFlix app) is failing.

Have you verified that the [TEST] and [PROD] fields in your .ini file have your Atlas SRV string?

Thanks,
Matt

1 Like

Since last night i’m waiting for the validation code but it doesn’t work

paste a screen shot of you pytest command

(mflix_venv) C:_Work\mongo\M220P\mflix-python>pytest -m connection
============================= test session starts =============================
platform win32 – Python 3.7.0, pytest-3.8.2, py-1.7.0, pluggy-0.8.0
rootdir: C:_Work\mongo\M220P\mflix-python, inifile:
plugins: flask-0.10.0
collected 35 items / 31 deselected

tests\test_db_connection.py … [100%]

============================== warnings summary ===============================
c:_work\mongo\m220p\mflix-python\mflix_venv\lib\site-packages\pytest_flask\plugin.py:109: DeprecationWarning: getfuncargvalue is deprecated, use getfixturevalue
app = request.getfuncargvalue(‘app’)
c:_work\mongo\m220p\mflix-python\mflix_venv\lib\site-packages\pytest_flask\plugin.py:61: DeprecationWarning: getfuncargvalue is deprecated, use getfixturevalue
app = request.getfuncargvalue(‘app’)
c:_work\mongo\m220p\mflix-python\mflix_venv\lib\site-packages\pytest_flask\plugin.py:78: DeprecationWarning: getfuncargvalue is deprecated, use getfixturevalue
app = request.getfuncargvalue(‘app’)

c:_work\mongo\m220p\mflix-python\mflix_venv\lib\site-packages\pytest_flask\plugin.py:109: DeprecationWarning: getfuncargvalue is deprecated, use getfixturevalue
app = request.getfuncargvalue(‘app’)
c:_work\mongo\m220p\mflix-python\mflix_venv\lib\site-packages\pytest_flask\plugin.py:61: DeprecationWarning: getfuncargvalue is deprecated, use getfixturevalue
app = request.getfuncargvalue(‘app’)
c:_work\mongo\m220p\mflix-python\mflix_venv\lib\site-packages\pytest_flask\plugin.py:78: DeprecationWarning: getfuncargvalue is deprecated, use getfixturevalue
app = request.getfuncargvalue(‘app’)

c:_work\mongo\m220p\mflix-python\mflix_venv\lib\site-packages\pytest_flask\plugin.py:109: DeprecationWarning: getfuncargvalue is deprecated, use getfixturevalue
app = request.getfuncargvalue(‘app’)
c:_work\mongo\m220p\mflix-python\mflix_venv\lib\site-packages\pytest_flask\plugin.py:61: DeprecationWarning: getfuncargvalue is deprecated, use getfixturevalue
app = request.getfuncargvalue(‘app’)
c:_work\mongo\m220p\mflix-python\mflix_venv\lib\site-packages\pytest_flask\plugin.py:78: DeprecationWarning: getfuncargvalue is deprecated, use getfixturevalue
app = request.getfuncargvalue(‘app’)

c:_work\mongo\m220p\mflix-python\mflix_venv\lib\site-packages\pytest_flask\plugin.py:109: DeprecationWarning: getfuncargvalue is deprecated, use getfixturevalue
app = request.getfuncargvalue(‘app’)
c:_work\mongo\m220p\mflix-python\mflix_venv\lib\site-packages\pytest_flask\plugin.py:61: DeprecationWarning: getfuncargvalue is deprecated, use getfixturevalue
app = request.getfuncargvalue(‘app’)
c:_work\mongo\m220p\mflix-python\mflix_venv\lib\site-packages\pytest_flask\plugin.py:78: DeprecationWarning: getfuncargvalue is deprecated, use getfixturevalue
app = request.getfuncargvalue(‘app’)

– Docs: https://docs.pytest.org/en/latest/warnings.html
============ 4 passed, 31 deselected, 12 warnings in 4.01 seconds =============

2 Likes

@ Djifferson

If its not coming back within a few seconds you have probably got a code error that has caused an unhandled exception. Look at your console window where you launched the website via command:

python run.py

You should see a syslog output of a whole load of HTTP GET/POST like mine below. Scroll through this and see if you can spot a Python exception message.

(mflix) D:\M220P>python run.py

  • Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
  • Restarting with stat
  • Debugger is active!
  • Debugger pin code: 263-374-917
    127.0.0.1 - - [22/Oct/2018 17:14:24] “GET /status HTTP/1.1” 200 -
    127.0.0.1 - - [22/Oct/2018 17:14:26] “GET /api/v1/movies/ HTTP/1.1” 200 -
    127.0.0.1 - - [22/Oct/2018 17:14:26] “GET /api/v1/movies/countries?countries=Australia HTTP/1.1” 200 -
    127.0.0.1 - - [22/Oct/2018 17:14:27] “GET /api/v1/movies/search?cast=Griffin%20Gluck HTTP/1.1” 200 -
    127.0.0.1 - - [22/Oct/2018 17:14:28] “GET /api/v1/movies/search?cast=Morgan%20Freeman&page=0 HTTP/1.1” 200 -
    127.0.0.1 - - [22/Oct/2018 17:14:28] “GET /api/v1/movies/facet-search?cast=Denzel%20Washington&page=0 HTTP/1.1” 200 -
    127.0.0.1 - - [22/Oct/2018 17:14:29] “POST /api/v1/user/register HTTP/1.1” 201 -
    127.0.0.1 - - [22/Oct/2018 17:14:30] “POST /api/v1/user/register HTTP/1.1” 201 -
    127.0.0.1 - - [22/Oct/2018 17:14:31] “POST /api/v1/user/register HTTP/1.1” 201 -
    127.0.0.1 - - [22/Oct/2018 17:14:31] “GET /api/v1/movies/id/573a13a7f29313caabd1aa1f HTTP/1.1” 200 -
    127.0.0.1 - - [22/Oct/2018 17:14:32] “POST /api/v1/user/register HTTP/1.1” 201 -
    127.0.0.1 - - [22/Oct/2018 17:14:33] “POST /api/v1/user/make-admin HTTP/1.1” 201 -
    127.0.0.1 - - [22/Oct/2018 17:14:34] “GET /api/v1/movies/id/573a1390f29313caabcd4132 HTTP/1.1” 200 -
    127.0.0.1 - - [22/Oct/2018 17:14:34] “GET /api/v1/movies/config-options HTTP/1.1” 200 -
    127.0.0.1 - - [22/Oct/2018 17:14:34] “GET /api/v1/movies/id/foobar HTTP/1.1” 400 -
    127.0.0.1 - - [22/Oct/2018 17:14:34] “GET /service-worker.js HTTP/1.1” 200 -
    127.0.0.1 - - [22/Oct/2018 17:14:34] “GET /favicon.ico HTTP/1.1” 200 -
    127.0.0.1 - - [22/Oct/2018 17:14:35] “GET /api/v1/movies/search?text=shawshank HTTP/1.1” 200 -
    127.0.0.1 - - [22/Oct/2018 17:14:35] “GET /api/v1/movies/search?cast=Morgan%20Freeman&page=1 HTTP/1.1” 200 -
    127.0.0.1 - - [22/Oct/2018 17:14:36] “GET /api/v1/movies/facet-search?cast=Morgan%20Freeman&page=2 HTTP/1.1” 200 -
    127.0.0.1 - - [22/Oct/2018 17:14:37] “POST /api/v1/user/register HTTP/1.1” 400 -
    127.0.0.1 - - [22/Oct/2018 17:14:37] “PUT /api/v1/user/update-preferences HTTP/1.1” 201 -
    127.0.0.1 - - [22/Oct/2018 17:14:38] “POST /api/v1/movies/comment HTTP/1.1” 200 -
    127.0.0.1 - - [22/Oct/2018 17:14:38] “POST /api/v1/movies/comment HTTP/1.1” 200 -

I found that this was happening to me because I was using a public IP rather than localhost to access the application.

In both of the screenshots provided, the user has omitted the address bar. PROTIP: Always include the address bar when providing a screenshot. Always include every bit of the screen possible. Even the date and time could turn out to be crucial data points that could help others to help you.

One thing that you may consider if you run into this is try opening chrome dev tools and check out the network tab. Do you see any of the resources failing? Next, open the console and check for javascript errors. Those will likely shed some more light on what is going wrong when you run into this issue.

1 Like

I encountered the same problem too…
What is the cause?
thanks

The problem appears if the website address <> localhost:5000
The start on port 5000 gave an error (Run.py - OSError: [WinError 10013]).
And I used other port (app.run(port=5551)) and received this problem.

Link localhost:5000 is directly used in javascript:
mflix\build\index.html
mflix\build\static\js\main.9cd550cb.js
mflix\build\static\js\main.a4491d28.js
mflix\build\static\js\main.eb78d1bb.js

I replaced localhost:5000 with localhost:5551 and the website works.

1 Like

Blegh, that’s pretty bad :frowning: Hard-coded settings.

Thanks for the heads-up, now I know where to poke and prod!


This is the error message i am getting.
image

pls help

Well, it seems that it can’t even connect to the database. So there’s that.

Have you verified the URI you entered into “.ini” by using the Mongo shell?

was able to fix it. thanks.

Good job :slight_smile:

Hello, Could you please help me out.

my mail is abhishekraj981994@gmail.com

Need helped I am not able to get validation code for connection, Tried searching all answer in discussion topic
Below is .ini fie i am using

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

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

Also i have uploaded http://localhost:5000/status screenshot and command prompt screenshoot.
Can any one please let me know how to resolve this issue