mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-03 21:37:49 -05:00
reload food objects to resolve inconsistent behavior
This commit is contained in:
@@ -99,8 +99,12 @@ def test_list_space(obj_1, obj_2, u1_s1, u1_s2, space_2):
|
|||||||
assert json.loads(u1_s1.get(reverse(LIST_URL)).content)['count'] == 2
|
assert json.loads(u1_s1.get(reverse(LIST_URL)).content)['count'] == 2
|
||||||
assert json.loads(u1_s2.get(reverse(LIST_URL)).content)['count'] == 0
|
assert json.loads(u1_s2.get(reverse(LIST_URL)).content)['count'] == 0
|
||||||
|
|
||||||
obj_1.space = space_2
|
with scopes_disabled():
|
||||||
obj_1.save()
|
# for some reason the 'path' attribute changes between the factory and the test
|
||||||
|
obj_1 = Food.objects.get(id=obj_1.id)
|
||||||
|
obj_2 = Food.objects.get(id=obj_2.id)
|
||||||
|
obj_1.space = space_2
|
||||||
|
obj_1.save()
|
||||||
|
|
||||||
assert json.loads(u1_s1.get(reverse(LIST_URL)).content)['count'] == 1
|
assert json.loads(u1_s1.get(reverse(LIST_URL)).content)['count'] == 1
|
||||||
assert json.loads(u1_s2.get(reverse(LIST_URL)).content)['count'] == 1
|
assert json.loads(u1_s2.get(reverse(LIST_URL)).content)['count'] == 1
|
||||||
@@ -494,10 +498,10 @@ def test_root_filter(obj_tree_1, obj_2, obj_3, u1_s1):
|
|||||||
def test_tree_filter(obj_tree_1, obj_2, obj_3, u1_s1):
|
def test_tree_filter(obj_tree_1, obj_2, obj_3, u1_s1):
|
||||||
with scope(space=obj_tree_1.space):
|
with scope(space=obj_tree_1.space):
|
||||||
# for some reason the 'path' attribute changes between the factory and the test when using both obj_tree and obj
|
# for some reason the 'path' attribute changes between the factory and the test when using both obj_tree and obj
|
||||||
|
obj_tree_1 = Food.objects.get(id=obj_tree_1.id)
|
||||||
parent = obj_tree_1.get_parent()
|
parent = obj_tree_1.get_parent()
|
||||||
obj_2.move(parent, node_location)
|
obj_2.move(parent, node_location)
|
||||||
obj_2 = Food.objects.get(id=obj_2.id)
|
obj_2 = Food.objects.get(id=obj_2.id)
|
||||||
obj_tree_1 = Food.objects.get(id=obj_tree_1.id)
|
|
||||||
parent = Food.objects.get(id=parent.id)
|
parent = Food.objects.get(id=parent.id)
|
||||||
|
|
||||||
# should return full tree starting at parent (obj_tree_1, obj_2), ignoring query filters
|
# should return full tree starting at parent (obj_tree_1, obj_2), ignoring query filters
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ class FoodFactory(factory.django.DjangoModelFactory):
|
|||||||
'cookbook.tests.factories.RecipeFactory', space=factory.SelfAttribute('..space')),
|
'cookbook.tests.factories.RecipeFactory', space=factory.SelfAttribute('..space')),
|
||||||
no_declaration=None
|
no_declaration=None
|
||||||
)
|
)
|
||||||
path = None
|
path = factory.LazyAttribute(lambda x: faker.numerify(text='%###'))
|
||||||
space = factory.SubFactory(SpaceFactory)
|
space = factory.SubFactory(SpaceFactory)
|
||||||
|
|
||||||
@factory.post_generation
|
@factory.post_generation
|
||||||
|
|||||||
Reference in New Issue
Block a user