def test_tailing_from_specific_date(database, connection):
    result_docs = []

    def delete(op_doc):
        append_doc = {'op': op_doc['op'], 'ns': op_doc['ns']}
        result_docs.append(append_doc)

    def operation():
        pass

    database['specific_trigger'].insert_one({'a': 6})
    database['specific_trigger'].delete_one({'a': 6})
    now = bson.timestamp.Timestamp(datetime.datetime.utcnow(), 0)

    trigger = mongotriggers.MongoTrigger(connection, since=now)
    trigger.register_delete_trigger(delete, database.name, 'specific_trigger')
    basic_trigger(trigger, operation)
    assert len(result_docs) == 1
    assert result_docs[0]['op'] == 'd'
    assert result_docs[0]['ns'] == 'test.specific_trigger'
def test_mongo_replica_secondary(mongo_secondary):
    with pytest.raises(TypeError):
        mongotriggers.MongoTrigger(mongo_secondary)
def test_mongos(mongos):
    with pytest.raises(TypeError):
        mongotriggers.MongoTrigger(mongos)
def test_not_replica(mongod_no_replica):
    with pytest.raises(TypeError):
        mongotriggers.MongoTrigger(mongod_no_replica)
def trigger(connection):
    mongotrigger = mongotriggers.MongoTrigger(connection)
    return mongotrigger