def test_check_bugzilla_user_account_not_found(mock_get): mock_response = mock.MagicMock() mock_response.status_code = 400 mock_response.json = mock.MagicMock(return_value={"code": 51}) def user_not_found(): raise HTTPError(response=mock_response) mock_response.raise_for_status.side_effect = user_not_found mock_get.return_value = mock_response assert not probe_expiry_alert.check_bugzilla_user_exists( "*****@*****.**", "")
def test_check_bugzilla_user_account_not_found_200(mock_get): mock_response = mock.MagicMock() mock_response.status_code = 200 mock_response.json = mock.MagicMock( return_value={ "message": None, "code": 100500, "documentation": "https://bmo.readthedocs.io/en/latest/api/", "error": True, }) mock_get.return_value = mock_response assert not probe_expiry_alert.check_bugzilla_user_exists( "*****@*****.**", "")
def test_check_bugzilla_user_account_active(mock_get): users = { "users": [{ "can_login": True, "is_new": False, "real_name": "test", "email": "*****@*****.**", "id": 123, "name": "test", }] } mock_response = mock.MagicMock() mock_response.json = mock.MagicMock(return_value=users) mock_get.return_value = mock_response assert probe_expiry_alert.check_bugzilla_user_exists("*****@*****.**", "")