SOLVED - Ticket: User_preferences - NameError: name 'writeConcern' is not defined

Hi,

I am getting the error NameError: name ‘writeConcern’ is not defined while running user_preferences test.

Could you please help me understand the issue?

Here is the error script:

    """
    Ticket: Durable Writes

    Please increase the durability of this method by using a non-default write
    concern with ``insert_one``.
    """

    try:
        # TODO: User Management
        # Insert a user with the "name", "email", and "password" fields.
        # TODO: Durable Writes
        # Use a more durable Write Concern for this operation.
      db.users.insert_one({"name": name, "email": email, "password": hashedpw}, {writeConcern: {w: "majority"}})

E NameError: name ‘writeConcern’ is not defined

mflix\db.py:411: NameError
_________________________ test_empty_prefs_are_valid __________________________

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

@pytest.mark.user_preferences
def test_empty_prefs_are_valid(client):
    new_prefs = {}
    result = update_prefs("foobaz@bar.com", new_prefs)
  assert result.matched_count == 1

E AttributeError: ‘dict’ object has no attribute ‘matched_count’

tests\test_user_preferences.py:67: AttributeError
============== 3 failed, 1 passed, 35 deselected in 5.57 seconds ==============

Thank you!

see here. (I do not think that is necessary to pass test)

@Yuri_52502: Thank you. The issue is resolved now.

However, I am getting another error. Could you please help me understand the error below? Thank you!

Error: AttributeError: ‘UpdateResult’ object has no attribute 'get’

================================== FAILURES ===================================
________________ test_invalid_user_should_not_have_preferences ________________

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

@pytest.mark.user_preferences
def test_invalid_user_should_not_have_preferences(client):
    # delete the test user if it exists
    delete_user('foobaz@bar.com')
    preferences = {
        "color": "green",
        "favorite_letter": "q",
        "favorite_number": 42
    }

    result = update_prefs('foobaz@bar.com', preferences)
  assert result.get('error', None) is not None

E AttributeError: ‘UpdateResult’ object has no attribute ‘get’

tests\test_user_preferences.py:18: AttributeError
============== 1 failed, 3 passed, 35 deselected in 8.01 seconds ==============