xync-schema 0.6.91__tar.gz → 0.6.92.dev1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {xync_schema-0.6.91/xync_schema.egg-info → xync_schema-0.6.92.dev1}/PKG-INFO +1 -1
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev1}/tests/test_db.py +6 -7
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev1}/xync_schema/models.py +33 -19
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev1/xync_schema.egg-info}/PKG-INFO +1 -1
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev1}/.env.sample +0 -0
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev1}/.gitignore +0 -0
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev1}/.pre-commit-config.yaml +0 -0
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev1}/README.md +0 -0
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev1}/makefile +0 -0
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev1}/pyproject.toml +0 -0
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev1}/setup.cfg +0 -0
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev1}/tests/__init__.py +0 -0
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev1}/xync_schema/__init__.py +0 -0
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev1}/xync_schema/enums.py +0 -0
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev1}/xync_schema/types.py +0 -0
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev1}/xync_schema.egg-info/SOURCES.txt +0 -0
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev1}/xync_schema.egg-info/dependency_links.txt +0 -0
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev1}/xync_schema.egg-info/requires.txt +0 -0
- {xync_schema-0.6.91 → xync_schema-0.6.92.dev1}/xync_schema.egg-info/top_level.txt +0 -0
|
@@ -7,23 +7,22 @@ from tortoise.backends.asyncpg import AsyncpgDBClient
|
|
|
7
7
|
from x_model import init_db
|
|
8
8
|
|
|
9
9
|
from xync_schema import models
|
|
10
|
-
from xync_schema.models import Ex
|
|
11
10
|
|
|
12
11
|
load_dotenv()
|
|
13
12
|
|
|
14
13
|
|
|
15
14
|
@pytest.fixture
|
|
16
|
-
async def
|
|
15
|
+
async def _dbc() -> AsyncpgDBClient:
|
|
17
16
|
await init_db(env("DB_URL"), models, True)
|
|
18
17
|
cn: AsyncpgDBClient = connections.get("default")
|
|
19
18
|
yield cn
|
|
20
19
|
await cn.close()
|
|
21
20
|
|
|
22
21
|
|
|
23
|
-
async def test_init_db(
|
|
24
|
-
assert isinstance(
|
|
22
|
+
async def test_init_db(_dbc):
|
|
23
|
+
assert isinstance(_dbc, AsyncpgDBClient), "DB corrupt"
|
|
25
24
|
|
|
26
25
|
|
|
27
|
-
async def test_models(
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
# async def test_models(_dbc):
|
|
27
|
+
# c = await models.Ex.first()
|
|
28
|
+
# assert isinstance(c, models.Ex), "No exs"
|
|
@@ -4,7 +4,17 @@ from datetime import datetime
|
|
|
4
4
|
from tortoise import fields
|
|
5
5
|
from tortoise.queryset import QuerySet
|
|
6
6
|
from tortoise import Model as BaseModel
|
|
7
|
-
from x_auth.models import
|
|
7
|
+
from x_auth.models import (
|
|
8
|
+
Model,
|
|
9
|
+
Username as Username,
|
|
10
|
+
User as TgUser,
|
|
11
|
+
Proxy as Proxy,
|
|
12
|
+
Session as Session,
|
|
13
|
+
Peer as Peer,
|
|
14
|
+
UpdateState as UpdateState,
|
|
15
|
+
Version as Version,
|
|
16
|
+
Country as BaseCountry,
|
|
17
|
+
)
|
|
8
18
|
from x_model.models import TsTrait, DatetimeSecField
|
|
9
19
|
|
|
10
20
|
from xync_schema.enums import (
|
|
@@ -21,11 +31,7 @@ from xync_schema.enums import (
|
|
|
21
31
|
)
|
|
22
32
|
|
|
23
33
|
|
|
24
|
-
class Country(
|
|
25
|
-
id = fields.SmallIntField(True)
|
|
26
|
-
code: int | None = fields.IntField(null=True)
|
|
27
|
-
short: str | None = fields.CharField(3, null=True)
|
|
28
|
-
name: str | None = fields.CharField(63, unique=True, null=True)
|
|
34
|
+
class Country(BaseCountry):
|
|
29
35
|
cur: fields.ForeignKeyRelation["Cur"] = fields.ForeignKeyField("models.Cur", related_name="countries")
|
|
30
36
|
curexs: fields.ManyToManyRelation["Curex"]
|
|
31
37
|
fiats: fields.BackwardFKRelation["Fiat"]
|
|
@@ -117,6 +123,7 @@ class Curex(BaseModel):
|
|
|
117
123
|
|
|
118
124
|
class Coinex(BaseModel):
|
|
119
125
|
coin: fields.ForeignKeyRelation[Coin] = fields.ForeignKeyField("models.Coin")
|
|
126
|
+
coin_id: int
|
|
120
127
|
ex: fields.ForeignKeyRelation[Ex] = fields.ForeignKeyField("models.Ex")
|
|
121
128
|
minimum: float = fields.FloatField(null=True)
|
|
122
129
|
|
|
@@ -180,10 +187,8 @@ class Person(Model, TsTrait):
|
|
|
180
187
|
pm_agents: fields.BackwardFKRelation["PmAgent"]
|
|
181
188
|
|
|
182
189
|
|
|
183
|
-
class User(
|
|
190
|
+
class User(TgUser, TsTrait):
|
|
184
191
|
status: UserStatus = fields.IntEnumField(UserStatus, default=UserStatus.SLEEP)
|
|
185
|
-
gmail_auth: dict = fields.JSONField(default={})
|
|
186
|
-
|
|
187
192
|
person: fields.OneToOneRelation[Person] = fields.OneToOneField("models.Person", related_name="user")
|
|
188
193
|
person_id: int
|
|
189
194
|
ref: fields.ForeignKeyNullableRelation["User"] = fields.ForeignKeyField(
|
|
@@ -195,15 +200,17 @@ class User(UserTg, TsTrait):
|
|
|
195
200
|
) # who can texts this user
|
|
196
201
|
contacted_with_id: int | None
|
|
197
202
|
|
|
198
|
-
|
|
203
|
+
actors: fields.BackwardFKRelation["Actor"]
|
|
204
|
+
contacts: fields.BackwardFKRelation["User"]
|
|
199
205
|
created_forums: fields.BackwardFKRelation["Forum"]
|
|
200
|
-
proteges: fields.BackwardFKRelation["User"]
|
|
201
206
|
creds: fields.BackwardFKRelation["Cred"]
|
|
202
|
-
actors: fields.BackwardFKRelation["Actor"]
|
|
203
207
|
# fiats: fields.BackwardFKRelation["Fiat"]
|
|
208
|
+
gmail: fields.BackwardOneToOneRelation["Gmail"]
|
|
209
|
+
forum: fields.BackwardOneToOneRelation["Forum"]
|
|
204
210
|
limits: fields.BackwardFKRelation["Limit"]
|
|
205
211
|
msgs: fields.BackwardFKRelation["Msg"]
|
|
206
|
-
|
|
212
|
+
proteges: fields.BackwardFKRelation["User"]
|
|
213
|
+
|
|
207
214
|
# vpn: fields.BackwardOneToOneRelation["Vpn"]
|
|
208
215
|
# invite_requests: fields.BackwardFKRelation["Invite"]
|
|
209
216
|
# invite_approvals: fields.BackwardFKRelation["Invite"]
|
|
@@ -231,6 +238,15 @@ class User(UserTg, TsTrait):
|
|
|
231
238
|
# computed = ["balance"]
|
|
232
239
|
|
|
233
240
|
|
|
241
|
+
class Gmail(Model):
|
|
242
|
+
login: str = fields.CharField(127)
|
|
243
|
+
password: str = fields.CharField(127)
|
|
244
|
+
auth: dict = fields.JSONField(default={})
|
|
245
|
+
updated_at: datetime | None = DatetimeSecField(auto_now=True)
|
|
246
|
+
|
|
247
|
+
user: fields.OneToOneRelation[User] = fields.OneToOneField("models.User", "gmail")
|
|
248
|
+
|
|
249
|
+
|
|
234
250
|
class Forum(Model, TsTrait):
|
|
235
251
|
id: int = fields.BigIntField(True)
|
|
236
252
|
joined: bool = fields.BooleanField(default=False)
|
|
@@ -258,9 +274,7 @@ class Actor(Model):
|
|
|
258
274
|
return client(self, headers=self.agent.auth.get("headers"), cookies=self.agent.auth.get("cookies"))
|
|
259
275
|
|
|
260
276
|
def in_client(self):
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
module_name = f"xync_client.{self.ex.name}.inAgent"
|
|
277
|
+
module_name = f"xync_client.{self.ex.name}.InAgent"
|
|
264
278
|
__import__(module_name)
|
|
265
279
|
client = sys.modules[module_name].InAgentClient
|
|
266
280
|
return client(self)
|
|
@@ -729,7 +743,7 @@ class Msg(Model):
|
|
|
729
743
|
|
|
730
744
|
class TestEx(Model):
|
|
731
745
|
ex: fields.ForeignKeyRelation[Ex] = fields.ForeignKeyField("models.Ex", related_name="tests")
|
|
732
|
-
|
|
746
|
+
ex_id: int
|
|
733
747
|
action: ExAction = fields.IntEnumField(ExAction)
|
|
734
748
|
ok: bool | None = fields.BooleanField(default=False, null=True)
|
|
735
749
|
updated_at: datetime | None = DatetimeSecField(auto_now=True)
|
|
@@ -737,7 +751,7 @@ class TestEx(Model):
|
|
|
737
751
|
_icon = "test-pipe"
|
|
738
752
|
_name = {"ex_id", "action", "ok"}
|
|
739
753
|
|
|
740
|
-
def repr(self
|
|
754
|
+
def repr(self):
|
|
741
755
|
return f"{self.ex_id} {self.action.name} {self.ok}"
|
|
742
756
|
|
|
743
757
|
class Meta:
|
|
@@ -758,7 +772,7 @@ class Vpn(Model):
|
|
|
758
772
|
_icon = "vpn"
|
|
759
773
|
_name = {"pub"}
|
|
760
774
|
|
|
761
|
-
def repr(self
|
|
775
|
+
def repr(self):
|
|
762
776
|
return self.user.username
|
|
763
777
|
|
|
764
778
|
class Meta:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|