Page MenuHomePhabricator

Fix Flaky TWL Oauth test in CICD
Open, Needs TriagePublicBUG REPORT

Description

One of our OAuth tests is flaky in CI, though it passes locally
https://github.com/WikipediaLibrary/TWLight/blob/82cfe0f1ba45ff2e262d3080202d8318f965829c/TWLight/users/tests.py#L1659-L1684

def test_create_user_and_editor(self, mock_urlopen):
    """
    OAuthBackend._create_user_and_editor() should:
    * create a user
        * with a suitable username and email
        * without a password
    * And a matching editor
    """
    oauth_backend = OAuthBackend()
    oauth_data = FAKE_IDENTITY_DATA
    identity = FAKE_IDENTITY


    mock_response = Mock()
    mock_response.read.side_effect = [json.dumps(oauth_data)] * 7
    mock_urlopen.return_value = mock_response


    user, editor = oauth_backend._create_user_and_editor(identity)


    self.assertEqual(user.email, "alice@example.com")
    self.assertEqual(user.username, "567823")
    self.assertFalse(user.has_usable_password())


    self.assertEqual(editor.user, user)
    self.assertEqual(editor.wp_sub, 567823)
    # We won't test the fields set by update_from_wikipedia, as they are
    # tested elsewhere.

For now, we're commenting out this test
https://github.com/WikipediaLibrary/TWLight/commit/3d2b8ba9a67c30e1d2b26f71798087ce00bcd171
but we should fix it

Related Objects