Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix manager.get (and/or allow partial save) #27

Open
timbu opened this issue Jan 28, 2014 · 0 comments
Open

fix manager.get (and/or allow partial save) #27

timbu opened this issue Jan 28, 2014 · 0 comments

Comments

@timbu
Copy link

timbu commented Jan 28, 2014

def test_save_with_placeholders(bound_manager):
    manager = bound_manager

    manager.save(CustomFieldsEntity)
    entity = CustomFieldsEntity(id=1, name="foo")
    manager.save(entity)

    loaded = manager.get(CustomFieldsEntity, id=1)
    data = manager.serialize(loaded)
    assert isinstance(data['name'], TranslatableString)

    loaded.extra1 = "value1"
    manager.save(loaded)

    reloaded = manager.get(CustomFieldsEntity, id=1)
    redata = manager.serialize(reloaded)
    assert isinstance(redata['name'], TranslatableString)
    assert isinstance(redata['extra1'], TranslatableString)

    translator = get_translator(manager)
    translated = translator.translate(redata)
    assert translated['name'] == 'foo'
    assert translated['extra1'] == 'value1'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant