Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Django Upgrade] [ENG-4072] The Rest - Part 2 #10072

Merged
12 changes: 8 additions & 4 deletions api_tests/nodes/views/test_node_detail.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# -*- coding: utf-8 -*-
import mock
import pytest
from django.utils import timezone
from future.moves.urllib.parse import urlparse
import mock
from nose.tools import * # noqa:

import pytest
from rest_framework import exceptions

from addons.wiki.tests.factories import WikiFactory, WikiVersionFactory
from api.base.settings.defaults import API_BASE
Expand Down Expand Up @@ -33,7 +34,6 @@
WithdrawnRegistrationFactory,
DraftNodeFactory,
)
from rest_framework import exceptions
from tests.base import fake
from tests.utils import assert_latest_log, assert_latest_log_not
from website.views import find_bookmark_collection
Expand Down Expand Up @@ -480,8 +480,12 @@ def test_node_shows_related_count_for_linked_by_relationships(self, app, user, p
assert res.json['data']['relationships']['linked_by_nodes']['links']['related']['meta']['count'] == 1
assert res.json['data']['relationships']['linked_by_registrations']['links']['related']['meta']['count'] == 1

log_date = timezone.now()
project_private.deleted_date = log_date
project_private.deleted = log_date
project_private.is_deleted = True
Comment on lines +483 to 486
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: somehow, when I tried project_private.remove_node(auth=Auth(user=user)), the node is not deleted though the method went through the process and returned True.

project_private.save()
registration.reload()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must reload the registration, otherwise, registration.registered_from has the project_private node as active instead of deleted. If not, when WithdrawnRegistrationFactory is called using this registration, it old project_private overrides the deleted project_private and breaks the next assertion on linked_by_nodes

project_public.reload()

res = app.get(url)
Expand Down