Esempio n. 1
0
def display_data():
    from foolscap.meta_data import NotesModel
    from foolscap.note_display import ServiceRules

    patch_load = 'foolscap.meta_data.models.load_meta'
    with patch(patch_load, return_value=FAKE_FOUR_NOTES_W_SUB):
        model = NotesModel()
        service_rules = ServiceRules(model)
        items = list(model)
        items = service_rules.order(items)
        items = service_rules.alphabetise(items)
        return service_rules.structure(items)
Esempio n. 2
0
def test_servicerules_order(note_model):
    service = ServiceRules(note_model)
    with patch.object(service, 'order_notes') as _call:
        service.order(['most_viewed'])
        _call.assert_called_once()
        _call.assert_called_with(['most_viewed'])

    # Setting this effects test_models.test_notemodel__init__
    # this might be a bug with pytest?
    #
    # assert _note_model.model_type == 'notes'
    # asserts false - 'tags' != 'notes'
    #
    # note_model.model_type = 'tags'

    with patch.object(note_model, 'model_type', 'tags'):
        service = ServiceRules(note_model)
        with patch.object(service, 'by_count') as _call:
            service.order(['most_viewed'])
            _call.assert_called_once()
            _call.assert_called_with(['most_viewed'])