Esempio n. 1
0
def error_is_raised_if_copy_kwarg_is_not_field():
    User = dodge.data_class("User", ["username", "password"])
    
    original = User("bob", "password1")
    assert_raises_regexp(
        TypeError, "__init__ does not take keyword argument",
        lambda: dodge.copy(original, salt="salty")
    )
Esempio n. 2
0
def copying_data_class_creates_distinct_object_with_same_field_values():
    User = dodge.data_class("User", ["username", "password"])
    
    original = User("bob", "password1")
    copy = dodge.copy(original)
    
    assert original is not copy
    assert_equal("bob", copy.username)
Esempio n. 3
0
def copying_data_class_creates_distinct_object_with_same_field_values():
    User = dodge.data_class("User", ["username", "password"])

    original = User("bob", "password1")
    copy = dodge.copy(original)

    assert original is not copy
    assert_equal("bob", copy.username)
Esempio n. 4
0
def copy_of_data_object_has_values_changed_to_copy_kwargs():
    User = dodge.data_class("User", ["username", "password"])
    
    original = User("bob", "password1")
    copy = dodge.copy(original, password="******")
    
    assert original is not copy
    assert_equal("password1", original.password)
    assert_equal("password2", copy.password)
Esempio n. 5
0
def copy_of_data_object_has_values_changed_to_copy_kwargs():
    User = dodge.data_class("User", ["username", "password"])

    original = User("bob", "password1")
    copy = dodge.copy(original, password="******")

    assert original is not copy
    assert_equal("password1", original.password)
    assert_equal("password2", copy.password)
Esempio n. 6
0
def error_is_raised_if_copy_kwarg_is_not_field():
    User = dodge.data_class("User", ["username", "password"])

    original = User("bob", "password1")
    assert_raises_regexp(TypeError, "__init__ does not take keyword argument",
                         lambda: dodge.copy(original, salt="salty"))