# Path: models.py
# class Item(BaseModel):
#     """
#     Item describes a product for the e-commerce platform.
# 
#     Attributes:
#         uuid (UUID): Item UUID
#         name (str): Name for the product
#         price (decimal.Decimal): Price for a single product
#         description (str): Product description
#         availability (int): Quantity of items available
#         category (str): Category group of the item
# 
#     """
#     uuid = UUIDField(unique=True)
#     name = CharField()
#     price = DecimalField(auto_round=True)
#     description = TextField()
#     availability = IntegerField()
#     category = TextField()
#     _schema = ItemSchema
#     _search_attributes = ['name', 'category', 'description']
# 
#     def __str__(self):
#         return '{}, {}, {}, {}'.format(
#             self.uuid,
#             self.name,
#             self.price,
#             self.description)
# 
#     def is_favorite(self, item):
#         for f in self.favorites:
#             if f.item_id == item.id:
#                 return True
#         return False
# 
# Path: tests/test_utils.py
# def mock_uuid_generator():
# def mock_datetime(*args):
#     def __init__(self, cls):
#     def __call__(self, created_at=mock_datetime(), uuid=None, **query):
# def get_all_models_names():
# def add_user(email, password, id=None, first_name='John', last_name='Doe'):
# def add_admin_user(email, psw, id=None):
# def add_address(user, country='Italy', city='Pistoia', post_code='51100',
#                 address='Via Verdi 12', phone='3294882773', id=None):
# def add_favorite(user, item, id=None):
# def json_favorite(item):
# def add_item(name='Item Test', price='15.99',
#              description='test test test', id=None, category='scarpe'):
# def open_with_auth(app, url, method, username, password, content_type, data):
# def clean_images():
# def setup_images():
# def count_order_items(order):
# def format_jsonapi_request(type_, data):
# def assert_valid_response(data, expected):
#     def sort_data_lists(data, attribute, key):
#     def included_sorter(i): return i['type']
#     def errors_sorter(e): return e['source']['pointer']
# def wrong_dump(data):
# class MockModelCreate:
#     AUTH_TYPE = 'Basic'
#     RESULTS = json.load(fo)
# 
# Path: tests/test_case.py
# class TestCase:
#     """
#     Created TestCase to avoid duplicated code in the other tests
#     """
#     TEST_DB = SqliteDatabase(':memory:')
# 
#     @classmethod
#     def setup_class(cls):
#         """
#         When a Test is created override the ``database`` attribute for all
#         the tables with a SqliteDatabase in memory.
#         """
#         for table in TABLES:
#             table._meta.database = cls.TEST_DB
#             table.create_table(fail_silently=True)
# 
#         cls.app = app.test_client()
# 
#     def setup_method(self):
#         """
#         When setting up a new test method clear all the tables
#         """
#         for table in TABLES:
#             table.delete().execute()


import json
import search
from models import Item
from tests import test_utils
from tests.test_case import TestCase


NAMES = [
    'scarpe', 'scarpine', 'scarpette', 'scarpe da ballo',
    'scarpe da ginnastica', 'scarponi', 'scarpacce',
    'sedie', 'sedie deco', 'sedie da cucina', 'set di sedie',
    'tavolo con sedie', 'tavolo con set di sedie', 'divano', 'divano letto',
    'letto', 'letto singolo', 'letto matrimoniale', 'letto francese',
    'poltrona', 'poltrona elettrica', 'sgabello', 'maglietta', 'canottiera',
    'pantaloni', 'mutande', 'tavolo', 'tavolo da cucina', 'tavolino', 'tavola',
    'tavola di legno', 'legno di tavola',
]


def get_names(objects):
    return [r.name for r in objects]



# Path: models.py
# class Item(BaseModel):
#     """
#     Item describes a product for the e-commerce platform.
# 
#     Attributes:
#         uuid (UUID): Item UUID
#         name (str): Name for the product
#         price (decimal.Decimal): Price for a single product
#         description (str): Product description
#         availability (int): Quantity of items available
#         category (str): Category group of the item
# 
#     """
#     uuid = UUIDField(unique=True)
#     name = CharField()
#     price = DecimalField(auto_round=True)
#     description = TextField()
#     availability = IntegerField()
#     category = TextField()
#     _schema = ItemSchema
#     _search_attributes = ['name', 'category', 'description']
# 
#     def __str__(self):
#         return '{}, {}, {}, {}'.format(
#             self.uuid,
#             self.name,
#             self.price,
#             self.description)
# 
#     def is_favorite(self, item):
#         for f in self.favorites:
#             if f.item_id == item.id:
#                 return True
#         return False
# 
# Path: tests/test_utils.py
# def mock_uuid_generator():
# def mock_datetime(*args):
#     def __init__(self, cls):
#     def __call__(self, created_at=mock_datetime(), uuid=None, **query):
# def get_all_models_names():
# def add_user(email, password, id=None, first_name='John', last_name='Doe'):
# def add_admin_user(email, psw, id=None):
# def add_address(user, country='Italy', city='Pistoia', post_code='51100',
#                 address='Via Verdi 12', phone='3294882773', id=None):
# def add_favorite(user, item, id=None):
# def json_favorite(item):
# def add_item(name='Item Test', price='15.99',
#              description='test test test', id=None, category='scarpe'):
# def open_with_auth(app, url, method, username, password, content_type, data):
# def clean_images():
# def setup_images():
# def count_order_items(order):
# def format_jsonapi_request(type_, data):
# def assert_valid_response(data, expected):
#     def sort_data_lists(data, attribute, key):
#     def included_sorter(i): return i['type']
#     def errors_sorter(e): return e['source']['pointer']
# def wrong_dump(data):
# class MockModelCreate:
#     AUTH_TYPE = 'Basic'
#     RESULTS = json.load(fo)
# 
# Path: tests/test_case.py
# class TestCase:
#     """
#     Created TestCase to avoid duplicated code in the other tests
#     """
#     TEST_DB = SqliteDatabase(':memory:')
# 
#     @classmethod
#     def setup_class(cls):
#         """
#         When a Test is created override the ``database`` attribute for all
#         the tables with a SqliteDatabase in memory.
#         """
#         for table in TABLES:
#             table._meta.database = cls.TEST_DB
#             table.create_table(fail_silently=True)
# 
#         cls.app = app.test_client()
# 
#     def setup_method(self):
#         """
#         When setting up a new test method clear all the tables
#         """
#         for table in TABLES:
#             table.delete().execute()


# Path: tests/test_searchitem.py
import json
import search
from models import Item
from tests import test_utils
from tests.test_case import TestCase



NAMES = [
    'scarpe', 'scarpine', 'scarpette', 'scarpe da ballo',
    'scarpe da ginnastica', 'scarponi', 'scarpacce',
    'sedie', 'sedie deco', 'sedie da cucina', 'set di sedie',
    'tavolo con sedie', 'tavolo con set di sedie', 'divano', 'divano letto',
    'letto', 'letto singolo', 'letto matrimoniale', 'letto francese',
    'poltrona', 'poltrona elettrica', 'sgabello', 'maglietta', 'canottiera',
    'pantaloni', 'mutande', 'tavolo', 'tavolo da cucina', 'tavolino', 'tavola',
    'tavola di legno', 'legno di tavola',
]


def get_names(objects):
    return [r.name for r in objects]



class TestSearchItems(TestCase):