Ejemplo n.º 1
0
def test_after_taxonomy_term_moved(app, db, root_taxonomy, sample_term,
                                   sample_term_2, child_term):
    terms = current_flask_taxonomies_es.list("root")
    assert len(terms) == 0
    after_taxonomy_term_moved.connect(move_term)
    after_taxonomy_term_moved.send(child_term)
    time.sleep(1)
    terms = current_flask_taxonomies_es.list("root")
    assert len(terms) > 0
Ejemplo n.º 2
0
def test_remove_old_es_term_4(app, db, sample_term, sample_term_2, child_term, root_taxonomy_2,
                              sample_term_21):
    timestamp = datetime.utcnow()
    current_flask_taxonomies_es._synchronize_es(timestamp=timestamp)
    time.sleep(1)
    timestamp = datetime.utcnow()
    current_flask_taxonomies_es._remove_old_es_term(timestamp=timestamp,
                                                    taxonomies=["root", "bla"])
    time.sleep(1)
    terms = current_flask_taxonomies_es.list("root")
    assert len(terms) == 0
    time.sleep(1)
    terms = current_flask_taxonomies_es.list("root_2")
    assert len(terms) == 1
Ejemplo n.º 3
0
def test_remove_old_es_term(app, db, sample_term, sample_term_2, child_term):
    timestamp = datetime.utcnow()
    current_flask_taxonomies_es._synchronize_es(timestamp=timestamp)
    time.sleep(1)
    terms = current_flask_taxonomies_es.list("root")
    time.sleep(1)
    assert len(terms) == 3
    current_flask_taxonomies_es._remove_old_es_term(timestamp=timestamp)
    time.sleep(1)
    terms = current_flask_taxonomies_es.list("root")
    assert len(terms) == 3
    timestamp = datetime.utcnow()
    current_flask_taxonomies_es._remove_old_es_term(timestamp=timestamp)
    time.sleep(1)
    terms = current_flask_taxonomies_es.list("root")
    assert len(terms) == 0
Ejemplo n.º 4
0
def test_synchronize_es_timestamp(app, db, sample_term, sample_term_2, child_term):
    timestamp = datetime.utcnow()
    current_flask_taxonomies_es._synchronize_es(timestamp=timestamp)
    time.sleep(1)
    terms = current_flask_taxonomies_es.list("root")
    time.sleep(1)
    assert len(terms) == 3
    pprint(terms)
    for term in terms:
        assert term['date_of_serialization'] == str(timestamp)
Ejemplo n.º 5
0
def test_list(app, db, root_taxonomy, sample_term, sample_term_2, sample_term_dict,
              sample_term_2_dict):
    current_flask_taxonomies_es.set(sample_term)
    current_flask_taxonomies_es.set(sample_term_2)
    time.sleep(1)
    results = current_flask_taxonomies_es.list("root")
    new_results = []
    for result in results:
        del result["date_of_serialization"]
        new_results.append(result)
    assert new_results == [sample_term_dict, sample_term_2_dict]
Ejemplo n.º 6
0
def test_reindex(app, db, root_taxonomy, sample_term, child_term):
    current_flask_taxonomies_es.set(sample_term)
    time.sleep(1)
    term1 = current_flask_taxonomies_es.get(sample_term.taxonomy.slug, sample_term.slug)
    timestamp1 = term1['date_of_serialization']
    time.sleep(1)
    reindex_timestamp = current_flask_taxonomies_es.reindex()
    time.sleep(1)
    term2 = current_flask_taxonomies_es.get(sample_term.taxonomy.slug, sample_term.slug)
    time.sleep(1)
    timestamp2 = term2["date_of_serialization"]
    assert timestamp1 != timestamp2
    time.sleep(1)
    terms = current_flask_taxonomies_es.list("root")
    assert len(terms) == 2
    for term in terms:
        assert term['date_of_serialization'] == str(reindex_timestamp)
Ejemplo n.º 7
0
def test_synchronize_es(app, db, sample_term, sample_term_2, child_term):
    current_flask_taxonomies_es._synchronize_es()
    time.sleep(1)
    terms = current_flask_taxonomies_es.list("root")
    time.sleep(1)
    assert len(terms) == 3
Ejemplo n.º 8
0
def list_(taxonomy: str):
    pprint(current_flask_taxonomies_es.list(taxonomy))