store: Remove unused client info storing functionality.

This commit is contained in:
Damir Jelić 2019-05-21 16:55:07 +02:00
parent a823d85cd8
commit 212baad49e
2 changed files with 1 additions and 55 deletions

View File

@ -14,7 +14,7 @@
import os
from collections import defaultdict
from typing import Dict, List, Optional, Tuple
from typing import List, Optional, Tuple
import attr
from nio.store import (Accounts, DeviceKeys, DeviceTrustState, TrustState,
@ -53,20 +53,6 @@ class ServerUsers(Model):
constraints = [SQL("UNIQUE(user_id,server_id)")]
class Clients(Model):
user_id = TextField()
token = TextField()
server = ForeignKeyField(
model=Servers,
column_name="server_id",
backref="clients",
on_delete="CASCADE"
)
class Meta:
constraints = [SQL("UNIQUE(user_id,token,server_id)")]
@attr.s
class ClientInfo:
user_id = attr.ib(type=str)
@ -91,7 +77,6 @@ class PanStore:
models = [
Accounts,
AccessTokens,
Clients,
Servers,
ServerUsers,
DeviceKeys,
@ -201,30 +186,6 @@ class PanStore:
except IndexError:
return None
@use_database
def save_client(self, server_name, client):
# type: (ClientInfo) -> None
server, _ = Servers.get_or_create(name=server_name)
Clients.replace(
user_id=client.user_id,
token=client.access_token,
server=server.id
).execute()
@use_database
def load_clients(self, server_name):
# type: () -> Dict[str, ClientInfo]
clients = dict()
server, _ = Servers.get_or_create(name=server_name)
for c in server.clients:
client = ClientInfo(c.user_id, c.token)
clients[c.token] = client
return clients
@use_database
def load_all_devices(self):
# type (str, str) -> Dict[str, Dict[str, DeviceStore]]

View File

@ -19,21 +19,6 @@ class TestClass(object):
token = panstore.load_access_token(user_id, device_id)
access_token == token
def test_child_clinets_storing(self, panstore, client):
server = faker.hostname()
clients = panstore.load_clients(server)
assert not clients
panstore.save_client(server, client)
clients = panstore.load_clients(server)
assert clients
client2 = faker.client()
panstore.save_client(server, client2)
clients = panstore.load_clients(server)
assert len(clients) == 2
def test_server_account_storing(self, panstore):
accounts = panstore.load_all_users()