product search with ranking is working
This commit is contained in:
@@ -467,8 +467,6 @@ class ProductSearchTest(TestCase):
|
||||
self.factory(tags="lunares/azules", description="zapatos rojos"),
|
||||
self.factory(tags="lunares/rojos", description="zapatos"),
|
||||
self.factory(attributes='"zapatos de campo", tono/oscuro'),
|
||||
# TODO: workaround for v3 with multi-word tags
|
||||
# self.factory(attributes='zapatos, "zapatos de campo", tono/oscuro'),
|
||||
]
|
||||
unexpected_instances = [
|
||||
self.factory(description="chanclas"),
|
||||
@@ -549,18 +547,29 @@ class FindRelatedProductsTest(APITestCase):
|
||||
# clear table
|
||||
self.model.objects.all().delete()
|
||||
|
||||
def test_v3_find_by_single_tag(self):
|
||||
def test_v3_find_by_tags(self):
|
||||
# create tagged product
|
||||
tag = 'cool'
|
||||
expected_instances = [
|
||||
self.factory(tags=tag)
|
||||
self.factory(tags=tag),
|
||||
self.factory(tags=f'{tag} hat'),
|
||||
self.factory(tags=f'temperatures/{tag}'),
|
||||
self.factory(tags=f'temperatures/{tag}, body/hot'),
|
||||
self.factory(tags=f'temperatures/{tag}, hats/{tag}'),
|
||||
# multiple hits
|
||||
self.factory(tags=tag, attributes=tag),
|
||||
self.factory(tags=tag, attributes=tag, category=tag),
|
||||
self.factory(tags=tag, attributes=tag, category=tag, name=tag),
|
||||
self.factory(tags=tag, attributes=tag, category=tag, name=tag, description=tag),
|
||||
]
|
||||
# instance = self.factory()
|
||||
# instance.tags.set(tag)
|
||||
# instance.save()
|
||||
|
||||
unexpected_instances = [
|
||||
self.factory(tags="notcool"), # shouldn't catch it
|
||||
self.factory(tags="azules"),
|
||||
]
|
||||
|
||||
# searh for it
|
||||
results = find_related_products_v3(tag)
|
||||
import ipdb; ipdb.set_trace()
|
||||
|
||||
# assert result
|
||||
self.assertTrue(len(results) == len(expected_instances))
|
||||
@@ -568,3 +577,4 @@ class FindRelatedProductsTest(APITestCase):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user