mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
backups: Rename network_storage module to store
Same module is being used to store/retrieve local disk repositories also. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
1 parent
5df34d1927
commit
0df07f5cf2
5 files changed
+62
-51
No files matched your search
+24
-21
@@ -20,26 +20,29 @@ Test network storage.
|
||||
|
||||
import pytest
|
||||
|
||||
from plinth.modules.backups import network_storage
|
||||
from plinth.modules.backups import store
|
||||
|
||||
pytestmark = pytest.mark.django_db
|
||||
|
||||
_storages = [{
|
||||
'path': 'test@nonexistent.org:~/',
|
||||
'storage_type': 'ssh',
|
||||
'added_by_module': 'test'
|
||||
}, {
|
||||
'path': 'test@nonexistent.org:~/tmp/repo/',
|
||||
'storage_type': 'ssh',
|
||||
'added_by_module': 'test'
|
||||
}]
|
||||
_storages = [
|
||||
{
|
||||
'path': 'test@nonexistent.org:~/',
|
||||
'storage_type': 'ssh',
|
||||
'added_by_module': 'test'
|
||||
},
|
||||
{
|
||||
'path': 'test@nonexistent.org:~/tmp/repo/',
|
||||
'storage_type': 'ssh',
|
||||
'added_by_module': 'test'
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
def test_add():
|
||||
"""Add a storage item"""
|
||||
storage = _storages[0]
|
||||
uuid = network_storage.update_or_add(storage)
|
||||
_storage = network_storage.get(uuid)
|
||||
uuid = store.update_or_add(storage)
|
||||
_storage = store.get(uuid)
|
||||
assert _storage['path'] == storage['path']
|
||||
|
||||
|
||||
@@ -50,7 +53,7 @@ def test_add_invalid():
|
||||
'added_by_module': 'test'
|
||||
}
|
||||
with pytest.raises(ValueError):
|
||||
network_storage.update_or_add(storage_with_missing_type)
|
||||
store.update_or_add(storage_with_missing_type)
|
||||
|
||||
|
||||
def test_remove():
|
||||
@@ -58,12 +61,12 @@ def test_remove():
|
||||
storage = _storages[0]
|
||||
uuid = None
|
||||
for storage in _storages:
|
||||
uuid = network_storage.update_or_add(storage)
|
||||
uuid = store.update_or_add(storage)
|
||||
|
||||
storages = network_storage.get_storages()
|
||||
storages = store.get_storages()
|
||||
assert len(storages) == 2
|
||||
network_storage.delete(uuid)
|
||||
storages = network_storage.get_storages()
|
||||
store.delete(uuid)
|
||||
storages = store.get_storages()
|
||||
assert len(storages) == 1
|
||||
|
||||
|
||||
@@ -71,11 +74,11 @@ def test_update():
|
||||
"""Update existing storage items"""
|
||||
uuid = None
|
||||
for storage in _storages:
|
||||
uuid = network_storage.update_or_add(storage)
|
||||
uuid = store.update_or_add(storage)
|
||||
|
||||
storage = network_storage.get(uuid)
|
||||
storage = store.get(uuid)
|
||||
new_path = 'test@nonexistent.org:~/tmp/repo_new/'
|
||||
storage['path'] = new_path
|
||||
network_storage.update_or_add(storage)
|
||||
_storage = network_storage.get(uuid)
|
||||
store.update_or_add(storage)
|
||||
_storage = store.get(uuid)
|
||||
assert _storage['path'] == new_path
|
||||
Reference in new issue
Block a user