Пример #1
0
def test_del_record_removes_a_record():
    """Tests that del_record will remove a record from the Store."""
    store = Store()

    store.add_record({"this": "that", "that": "foo"})
    assert len(store) == 1
    store.del_record({"this": "that", "that": "foo"})
    assert len(store) == 0
Пример #2
0
def _create_store():
    """Simple helper function which creates a Store with some initial
    values and returns it."""
    store = Store([{
        "this": "that",
        "that": "foo"
    }, {
        "this": "that",
        "that": "bar"
    }, {
        "this": "that",
        "that": "baz"
    }, {
        "this": "foo",
        "that": "this"
    }, {
        "this": "bar",
        "that": "this"
    }, {
        "this": "baz",
        "that": "this"
    }])
    return store
Пример #3
0
from forms.register_form import RegisterForm
from forms.login_form import LoginForm
from forms.search_form import SearchForm
import random
import json

# Запуск приложения через flask
app = Flask(__name__)
app.config['SECRET_KEY'] = 'yandexlyceum_store_secret_key'
# Создание менеджера логинов
login_manager = LoginManager()
login_manager.init_app(app)
# Подключение к базе данных
db_session.global_init("db/store_database.db")
# Создание магазина - заглушки
store = Store()


# Функция выбирает случайный магазин из базы данных
def set_current_store():
    global store
    session = db_session.create_session()
    stores = session.query(Store).all()
    store = random.choice(stores)


# Получение данных от текущего магазина
# Это нужно, чтобы легко менять название страниц
def get_store_settings():
    store_settings = dict()
    store_settings['title'] = store.name
Пример #4
0
def test_Store_constructor_adds__id_field_to_each_record():
    """Tests that even if you don't specify an '_id' field,
    one will be created for each record."""
    store = Store([{}, {}])
    for record in store:
        assert "_id" in record
Пример #5
0
def test_Store_constructor_accepts_a_list_of_dicts_to_initialize():
    """Tests that if you pass a list of dicts to the Store constructor
    you will initialize Store with those records."""
    store = Store([{}, {}])
    assert len(store) == 2
Пример #6
0
def test_Store_returns_empty_store():
    """Tests that initializing a store with no values produces an
    empty Store."""
    store = Store()
    assert len(store) == 0
Пример #7
0
def test_add_record_adds_a_record():
    """Tests that the Store's add_record method adds a record to Store."""
    store = Store()

    store.add_record({"this": "that", "that": "foo"})
    assert len(store) == 1