fix tests
This commit is contained in:
parent
aa6b8be647
commit
7a01e8b1d3
@ -93,17 +93,6 @@ class KeywordAdmin(TreeAdmin):
|
||||
form = movenodeform_factory(Keyword)
|
||||
ordering = ('space', 'path',)
|
||||
|
||||
# removing ability to delete keywords from admin
|
||||
# to avoid creating orphaned keywords
|
||||
# def get_actions(self, request):
|
||||
# actions = super().get_actions(request)
|
||||
# if 'delete_selected' in actions:
|
||||
# del actions['delete_selected']
|
||||
# return actions
|
||||
|
||||
# def has_delete_permission(self, request, obj=None):
|
||||
# return False
|
||||
|
||||
|
||||
admin.site.register(Keyword, KeywordAdmin)
|
||||
|
||||
@ -144,7 +133,14 @@ class RecipeAdmin(admin.ModelAdmin):
|
||||
admin.site.register(Recipe, RecipeAdmin)
|
||||
|
||||
admin.site.register(Unit)
|
||||
admin.site.register(Food)
|
||||
|
||||
|
||||
class FoodAdmin(TreeAdmin):
|
||||
form = movenodeform_factory(Keyword)
|
||||
ordering = ('space', 'path',)
|
||||
|
||||
|
||||
admin.site.register(Food, FoodAdmin)
|
||||
|
||||
|
||||
class IngredientAdmin(admin.ModelAdmin):
|
||||
|
@ -429,7 +429,7 @@ def test_root_filter(obj_1, obj_1_1, obj_1_1_1, obj_2, obj_3, u1_s1):
|
||||
assert len(response['results']) == 2
|
||||
|
||||
with scopes_disabled():
|
||||
obj_2.move(obj_1, 'sorted-child')
|
||||
obj_2.move(obj_1, 'last-child')
|
||||
# should return direct children of obj_1 (obj_1_1, obj_2), ignoring query filters
|
||||
response = json.loads(u1_s1.get(f'{reverse(LIST_URL)}?root={obj_1.id}').content)
|
||||
assert response['count'] == 2
|
||||
@ -439,7 +439,7 @@ def test_root_filter(obj_1, obj_1_1, obj_1_1_1, obj_2, obj_3, u1_s1):
|
||||
|
||||
def test_tree_filter(obj_1, obj_1_1, obj_1_1_1, obj_2, obj_3, u1_s1):
|
||||
with scopes_disabled():
|
||||
obj_2.move(obj_1, 'sorted-child')
|
||||
obj_2.move(obj_1, 'last-child')
|
||||
# should return full tree starting at obj_1 (obj_1_1_1, obj_2), ignoring query filters
|
||||
response = json.loads(u1_s1.get(f'{reverse(LIST_URL)}?tree={obj_1.id}').content)
|
||||
assert response['count'] == 4
|
||||
|
@ -350,7 +350,7 @@ def test_root_filter(obj_1, obj_1_1, obj_1_1_1, obj_2, obj_3, u1_s1):
|
||||
assert len(response['results']) == 2
|
||||
|
||||
with scopes_disabled():
|
||||
obj_2.move(obj_1, 'sorted-child')
|
||||
obj_2.move(obj_1, 'last-child')
|
||||
# should return direct children of obj_1 (obj_1_1, obj_2), ignoring query filters
|
||||
response = json.loads(u1_s1.get(f'{reverse(LIST_URL)}?root={obj_1.id}').content)
|
||||
assert response['count'] == 2
|
||||
@ -360,7 +360,7 @@ def test_root_filter(obj_1, obj_1_1, obj_1_1_1, obj_2, obj_3, u1_s1):
|
||||
|
||||
def test_tree_filter(obj_1, obj_1_1, obj_1_1_1, obj_2, obj_3, u1_s1):
|
||||
with scopes_disabled():
|
||||
obj_2.move(obj_1, 'sorted-child')
|
||||
obj_2.move(obj_1, 'last-child')
|
||||
# should return full tree starting at obj_1 (obj_1_1_1, obj_2), ignoring query filters
|
||||
response = json.loads(u1_s1.get(f'{reverse(LIST_URL)}?tree={obj_1.id}').content)
|
||||
assert response['count'] == 4
|
||||
|
@ -191,7 +191,7 @@ class MergeMixin(ViewSetMixin): # TODO update Units to use merge API
|
||||
if isTree:
|
||||
children = source.get_children().exclude(id=target.id)
|
||||
for c in children:
|
||||
c.move(target, 'sorted-child')
|
||||
c.move(target, 'last-child')
|
||||
content = {'msg': _(f'{source.name} was merged successfully with {target.name}')}
|
||||
source.delete()
|
||||
return Response(content, status=status.HTTP_200_OK)
|
||||
@ -244,7 +244,7 @@ class TreeMixin(MergeMixin, FuzzyFilterMixin):
|
||||
if parent == 0:
|
||||
try:
|
||||
with scopes_disabled():
|
||||
child.move(self.model.get_first_root_node(), 'sorted-sibling')
|
||||
child.move(self.model.get_first_root_node(), 'last-sibling')
|
||||
content = {'msg': _(f'{child.name} was moved successfully to the root.')}
|
||||
return Response(content, status=status.HTTP_200_OK)
|
||||
except (PathOverflow, InvalidMoveToDescendant, InvalidPosition):
|
||||
@ -262,7 +262,7 @@ class TreeMixin(MergeMixin, FuzzyFilterMixin):
|
||||
|
||||
try:
|
||||
with scopes_disabled():
|
||||
child.move(parent, 'sorted-child')
|
||||
child.move(parent, 'last-child')
|
||||
content = {'msg': _(f'{child.name} was moved successfully to parent {parent.name}')}
|
||||
return Response(content, status=status.HTTP_200_OK)
|
||||
except (PathOverflow, InvalidMoveToDescendant, InvalidPosition):
|
||||
|
Loading…
Reference in New Issue
Block a user