Add test update

This commit is contained in:
Andros Fenollosa 2022-12-05 14:02:22 +01:00
parent 26f8caa3d2
commit 7f00126742
3 changed files with 109 additions and 8 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
dist/ dist/
build/ build/
fiable_db.egg-info/ fiable_db.egg-info/
/fiabledb.json

View File

@ -167,26 +167,126 @@ def test_update_table():
}, },
] ]
def test_update_table_not_exists(): def test_update_table_not_exists():
"""Test update in a table that not exists.""" """Test update in a table that not exists."""
pass start()
add({"name": "Antony", "age": 77, "height": 188}, table="users")
update(1, {"name": "David"}, table="boo")
assert get_database() == [
{
"id": 1,
"rev": 1,
"table": "users",
"data": {"name": "Antony", "age": 77, "height": 188},
}
]
def test_update_id_not_exists(): def test_update_id_not_exists():
"""Test update with an id that not exists.""" """Test update with an id that not exists."""
pass start()
add({"name": "Antony", "age": 77, "height": 188}, table="users")
update(2, {"name": "David"}, table="users")
assert get_database() == [
{
"id": 1,
"rev": 1,
"table": "users",
"data": {"name": "Antony", "age": 77, "height": 188},
}
]
def test_update_multiple_values_default(): def test_update_multiple_values_default():
"""Test update multiple values in the default table.""" """Test update multiple values in the default table."""
pass start()
add({"name": "Antony", "age": 77, "height": 188})
add({"name": "Dolores", "age": 32})
update(1, {"name": "David", "age": 9})
assert get_database() == [
{
"id": 1,
"rev": 1,
"table": "default",
"data": {"name": "David", "age": 9, "height": 188},
},
{
"id": 2,
"rev": 1,
"table": "default",
"data": {"name": "Dolores", "age": 32},
},
]
def test_update_multiple_values_table(): def test_update_multiple_values_table():
"""Test update multiple values in a table.""" """Test update multiple values in a table."""
pass start()
add({"name": "Antony", "age": 77, "height": 188}, table="users")
add({"name": "Dolores", "age": 32}, table="users")
update(1, {"name": "David", "age": 9}, table="users")
assert get_database() == [
{
"id": 1,
"rev": 1,
"table": "users",
"data": {"name": "David", "age": 9, "height": 188},
},
{
"id": 2,
"rev": 1,
"table": "users",
"data": {"name": "Dolores", "age": 32},
},
]
def test_update_with_keys_not_exists(): def test_update_with_keys_not_exists():
"""Test update with keys that not exists.""" """Test update with keys that not exists."""
pass start()
add({"name": "Antony", "age": 77, "height": 188})
add({"name": "Dolores", "age": 32})
update(1, {"is_active": True, "eyes": "blue"})
assert get_database() == [
{
"id": 1,
"rev": 1,
"table": "default",
"data": {
"name": "Antony",
"age": 77,
"height": 188,
"is_active": True,
"eyes": "blue",
},
},
{
"id": 2,
"rev": 1,
"table": "default",
"data": {"name": "Dolores", "age": 32},
},
]
def test_update_with_force(): def test_update_with_force():
"""Test update with force.""" """Test update with force."""
pass start()
add({"name": "Antony", "age": 77, "height": 188})
add({"name": "Dolores", "age": 32})
update(1, {"name": "David", "age": 9}, force=True)
assert get_database() == [
{
"id": 1,
"rev": 1,
"table": "default",
"data": {"name": "David", "age": 9},
},
{
"id": 2,
"rev": 1,
"table": "default",
"data": {"name": "Dolores", "age": 32},
},
]

View File

@ -1,5 +1,5 @@
* Tasks * Tasks
** DONE Add table in add testing
** IN PROGRESS Test update ** IN PROGRESS Test update
** TODO Function update ** TODO Function update
** DONE Add table in add testing