# Path: multiseek/logic.py
# DATE = "date"
# 
# AUTOCOMPLETE = "autocomplete"
# 
# RANGE = "range"
# 
# STRING = "string"
# 
# VALUE_LIST = "value-list"
# 
# def get_registry(registry):
#     """
#     :rtype: MultiseekRegistry
#     """
# 
#     if isinstance(registry, str):
#         if registry not in _cached_registry:
#             m = importlib.import_module(registry).registry
#             _cached_registry[registry] = m
#         return _cached_registry[registry]
# 
#     return registry
# 
# Path: test_project/test_app/models.py
# class Language(models.Model):
#     name = models.TextField()
#     description = models.TextField()
# 
#     def __str__(self):
#         return self.name
# 
# class Author(models.Model):
#     last_name = models.TextField()
#     first_name = models.TextField()
# 
#     def __str__(self):
#         return u"%s %s" % (self.first_name, self.last_name)
# 
# class Book(models.Model):
#     title = models.TextField()
#     year = models.IntegerField()
#     language = models.ForeignKey(Language, on_delete=models.CASCADE)
#     authors = models.ManyToManyField(Author)
#     no_editors = models.IntegerField()
#     last_updated = models.DateField(auto_now=True)
#     available = models.BooleanField(default=False)
# 
#     def __str__(self):
#         return u"%s by %s" % (self.title, u", ".join(
#             [str(author) for author in self.authors.all()]))
# 
# Path: test_project/test_app/testutil.py
# class wait_for_page_load(object):
#     def __init__(self, browser):
#         self.browser = browser
# 
#     def __enter__(self):
#         self.old_page = self.browser.find_by_tag("html")[0]._element
# 
#     def __exit__(self, *_):
#         WebDriverWait(self.browser, 10).until(
#             lambda driver: staleness_of(self.old_page)
#         )


import json
import pytest
import datetime
from django.conf import settings
from django.urls import reverse
from model_bakery import baker
from selenium.webdriver.support.expected_conditions import staleness_of, \
    alert_is_present
from selenium.webdriver.support.ui import WebDriverWait
from splinter.exceptions import ElementDoesNotExist
from multiseek.logic import DATE, AUTOCOMPLETE, RANGE, STRING, VALUE_LIST, \
    get_registry
from .models import Language, Author, Book
from builtins import str as text
from django.utils.translation import gettext_lazy as _
from .testutil import wait_for_page_load
            ret[elem] = e

        selected = ret['type'].value
        ret['selected'] = selected

        inner_type = self.registry.field_by_name.get(selected).type
        ret['inner_type'] = inner_type

        if inner_type in [STRING, VALUE_LIST]:
            ret['value_widget'] = element.find_by_id("value")

        elif inner_type == RANGE:
            ret['value_widget'] = [
                element.find_by_id("value_min"),
                element.find_by_id("value_max")]

        elif inner_type == DATE:
            ret['value_widget'] = [
                element.find_by_id("value"),
                element.find_by_id("value_max")]

        elif inner_type == AUTOCOMPLETE:
            ret['value_widget'] = element.find_by_id("value")

        else:
            raise NotImplementedError(inner_type)

        code = '$("#%s").multiseekField("getValue")' % element['id']
        ret['value'] = self.browser.evaluate_script(code)


# Path: multiseek/logic.py
# DATE = "date"
# 
# AUTOCOMPLETE = "autocomplete"
# 
# RANGE = "range"
# 
# STRING = "string"
# 
# VALUE_LIST = "value-list"
# 
# def get_registry(registry):
#     """
#     :rtype: MultiseekRegistry
#     """
# 
#     if isinstance(registry, str):
#         if registry not in _cached_registry:
#             m = importlib.import_module(registry).registry
#             _cached_registry[registry] = m
#         return _cached_registry[registry]
# 
#     return registry
# 
# Path: test_project/test_app/models.py
# class Language(models.Model):
#     name = models.TextField()
#     description = models.TextField()
# 
#     def __str__(self):
#         return self.name
# 
# class Author(models.Model):
#     last_name = models.TextField()
#     first_name = models.TextField()
# 
#     def __str__(self):
#         return u"%s %s" % (self.first_name, self.last_name)
# 
# class Book(models.Model):
#     title = models.TextField()
#     year = models.IntegerField()
#     language = models.ForeignKey(Language, on_delete=models.CASCADE)
#     authors = models.ManyToManyField(Author)
#     no_editors = models.IntegerField()
#     last_updated = models.DateField(auto_now=True)
#     available = models.BooleanField(default=False)
# 
#     def __str__(self):
#         return u"%s by %s" % (self.title, u", ".join(
#             [str(author) for author in self.authors.all()]))
# 
# Path: test_project/test_app/testutil.py
# class wait_for_page_load(object):
#     def __init__(self, browser):
#         self.browser = browser
# 
#     def __enter__(self):
#         self.old_page = self.browser.find_by_tag("html")[0]._element
# 
#     def __exit__(self, *_):
#         WebDriverWait(self.browser, 10).until(
#             lambda driver: staleness_of(self.old_page)
#         )


# Path: test_project/test_app/conftest.py
import json
import pytest
import datetime
from django.conf import settings
from django.urls import reverse
from model_bakery import baker
from selenium.webdriver.support.expected_conditions import staleness_of, \
    alert_is_present
from selenium.webdriver.support.ui import WebDriverWait
from splinter.exceptions import ElementDoesNotExist
from multiseek.logic import DATE, AUTOCOMPLETE, RANGE, STRING, VALUE_LIST, \
    get_registry
from .models import Language, Author, Book
from builtins import str as text
from django.utils.translation import gettext_lazy as _
from .testutil import wait_for_page_load

            ret[elem] = e

        selected = ret['type'].value
        ret['selected'] = selected

        inner_type = self.registry.field_by_name.get(selected).type
        ret['inner_type'] = inner_type

        if inner_type in [STRING, VALUE_LIST]:
            ret['value_widget'] = element.find_by_id("value")

        elif inner_type == RANGE:
            ret['value_widget'] = [
                element.find_by_id("value_min"),
                element.find_by_id("value_max")]

        elif inner_type == DATE:
            ret['value_widget'] = [
                element.find_by_id("value"),
                element.find_by_id("value_max")]

        elif inner_type == AUTOCOMPLETE:
            ret['value_widget'] = element.find_by_id("value")

        else:
            raise NotImplementedError(inner_type)

        code = '$("#%s").multiseekField("getValue")' % element['id']
        ret['value'] = self.browser.evaluate_script(code)


        if ret['inner_type'] in (DATE, AUTOCOMPLETE, RANGE):