yhttp-dbmanager 2.8.1__tar.gz → 3.0.2__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.
- {yhttp_dbmanager-2.8.1/yhttp_dbmanager.egg-info → yhttp_dbmanager-3.0.2}/PKG-INFO +11 -6
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.2}/README.md +9 -4
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.2}/setup.py +8 -3
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.2}/tests/test_cli.py +12 -3
- yhttp_dbmanager-3.0.2/tests/test_dbmanager.py +22 -0
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.2}/tests/test_dburi.py +17 -4
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.2}/tests/test_install.py +3 -3
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.2}/yhttp/ext/dbmanager/__init__.py +2 -2
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.2}/yhttp/ext/dbmanager/cli.py +4 -4
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.2}/yhttp/ext/dbmanager/dbmanager.py +3 -2
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.2}/yhttp/ext/dbmanager/install.py +3 -3
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.2}/yhttp/ext/dbmanager/uri.py +16 -7
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.2/yhttp_dbmanager.egg-info}/PKG-INFO +11 -6
- yhttp_dbmanager-3.0.2/yhttp_dbmanager.egg-info/requires.txt +2 -0
- yhttp_dbmanager-2.8.1/tests/test_dbmanager.py +0 -28
- yhttp_dbmanager-2.8.1/yhttp_dbmanager.egg-info/requires.txt +0 -2
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.2}/LICENSE +0 -0
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.2}/setup.cfg +0 -0
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.2}/yhttp_dbmanager.egg-info/SOURCES.txt +0 -0
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.2}/yhttp_dbmanager.egg-info/dependency_links.txt +0 -0
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.2}/yhttp_dbmanager.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: yhttp-dbmanager
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0.2
|
|
4
4
|
Summary: Database manager command line interface and API for yhttp.
|
|
5
5
|
Home-page: http://github.com/yhttp/yhttp-dbmanager
|
|
6
6
|
Author: Vahid Mardani
|
|
@@ -22,7 +22,7 @@ Classifier: Topic :: Software Development :: Libraries
|
|
|
22
22
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
23
|
Description-Content-Type: text/markdown
|
|
24
24
|
License-File: LICENSE
|
|
25
|
-
Requires-Dist: yhttp<
|
|
25
|
+
Requires-Dist: yhttp<6,>=5
|
|
26
26
|
Requires-Dist: psycopg2
|
|
27
27
|
|
|
28
28
|
# yhttp-dbmanager
|
|
@@ -33,7 +33,7 @@ API.
|
|
|
33
33
|
## Contribution
|
|
34
34
|
|
|
35
35
|
### Dependencies
|
|
36
|
-
Install `
|
|
36
|
+
Install `postgresql` brefore use of this project.
|
|
37
37
|
```bash
|
|
38
38
|
apt install postgresql
|
|
39
39
|
```
|
|
@@ -82,12 +82,17 @@ make test
|
|
|
82
82
|
|
|
83
83
|
Execute specific test(s) using wildcard:
|
|
84
84
|
```bash
|
|
85
|
-
make test
|
|
85
|
+
make test F=tests/test_db*
|
|
86
|
+
make test F=tests/test_form.py::test_querystringform
|
|
86
87
|
```
|
|
87
88
|
|
|
88
|
-
|
|
89
|
+
*refer to* [pytest documentation](https://docs.pytest.org/en/7.1.x/how-to/usage.html#how-to-invoke-pytest)
|
|
90
|
+
*for more info about invoking tests.*
|
|
91
|
+
|
|
92
|
+
Execute tests and report coverage result:
|
|
89
93
|
```bash
|
|
90
94
|
make cover
|
|
95
|
+
make cover F=tests/test_static.py
|
|
91
96
|
make cover-html
|
|
92
97
|
```
|
|
93
98
|
|
|
@@ -118,7 +123,7 @@ Execute:
|
|
|
118
123
|
```bash
|
|
119
124
|
make clean
|
|
120
125
|
```
|
|
121
|
-
to clean-up previous dist
|
|
126
|
+
to clean-up previous `dist/*` and `build/*` directories.
|
|
122
127
|
|
|
123
128
|
|
|
124
129
|
### PyPI
|
|
@@ -6,7 +6,7 @@ API.
|
|
|
6
6
|
## Contribution
|
|
7
7
|
|
|
8
8
|
### Dependencies
|
|
9
|
-
Install `
|
|
9
|
+
Install `postgresql` brefore use of this project.
|
|
10
10
|
```bash
|
|
11
11
|
apt install postgresql
|
|
12
12
|
```
|
|
@@ -55,12 +55,17 @@ make test
|
|
|
55
55
|
|
|
56
56
|
Execute specific test(s) using wildcard:
|
|
57
57
|
```bash
|
|
58
|
-
make test
|
|
58
|
+
make test F=tests/test_db*
|
|
59
|
+
make test F=tests/test_form.py::test_querystringform
|
|
59
60
|
```
|
|
60
61
|
|
|
61
|
-
|
|
62
|
+
*refer to* [pytest documentation](https://docs.pytest.org/en/7.1.x/how-to/usage.html#how-to-invoke-pytest)
|
|
63
|
+
*for more info about invoking tests.*
|
|
64
|
+
|
|
65
|
+
Execute tests and report coverage result:
|
|
62
66
|
```bash
|
|
63
67
|
make cover
|
|
68
|
+
make cover F=tests/test_static.py
|
|
64
69
|
make cover-html
|
|
65
70
|
```
|
|
66
71
|
|
|
@@ -91,7 +96,7 @@ Execute:
|
|
|
91
96
|
```bash
|
|
92
97
|
make clean
|
|
93
98
|
```
|
|
94
|
-
to clean-up previous dist
|
|
99
|
+
to clean-up previous `dist/*` and `build/*` directories.
|
|
95
100
|
|
|
96
101
|
|
|
97
102
|
### PyPI
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
from setuptools import setup
|
|
2
1
|
import os.path
|
|
3
2
|
import re
|
|
4
3
|
|
|
4
|
+
from setuptools import setup, find_namespace_packages
|
|
5
|
+
|
|
5
6
|
|
|
6
7
|
# reading package's version (same way sqlalchemy does)
|
|
7
8
|
with open(
|
|
@@ -17,7 +18,7 @@ with open(
|
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
dependencies = [
|
|
20
|
-
'yhttp >=
|
|
21
|
+
'yhttp >= 5, < 6',
|
|
21
22
|
'psycopg2',
|
|
22
23
|
]
|
|
23
24
|
|
|
@@ -32,7 +33,11 @@ setup(
|
|
|
32
33
|
long_description=open('README.md').read(),
|
|
33
34
|
long_description_content_type='text/markdown', # This is important!
|
|
34
35
|
install_requires=dependencies,
|
|
35
|
-
packages=
|
|
36
|
+
packages=find_namespace_packages(
|
|
37
|
+
where='./',
|
|
38
|
+
include=['yhttp.ext.dbmanager'],
|
|
39
|
+
exclude=['tests']
|
|
40
|
+
),
|
|
36
41
|
license='MIT',
|
|
37
42
|
classifiers=[
|
|
38
43
|
'Environment :: Console',
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
1
3
|
from bddcli import Given, Application as CLIApplication, status, stderr, \
|
|
2
4
|
when, stdout
|
|
3
5
|
import easycli
|
|
4
|
-
from yhttp import Application
|
|
6
|
+
from yhttp.core import Application
|
|
7
|
+
|
|
5
8
|
from yhttp.ext.dbmanager import install
|
|
6
9
|
|
|
7
10
|
|
|
@@ -20,10 +23,16 @@ db:
|
|
|
20
23
|
install(app, cliarguments=[Bar])
|
|
21
24
|
|
|
22
25
|
|
|
23
|
-
def test_applicationcli():
|
|
26
|
+
def test_applicationcli(cicd):
|
|
24
27
|
app.ready()
|
|
25
28
|
cliapp = CLIApplication('example', 'tests.test_cli:app.climain')
|
|
26
|
-
|
|
29
|
+
env = os.environ.copy()
|
|
30
|
+
if cicd:
|
|
31
|
+
env.setdefault('YHTTP_DB_DEFAULT_HOST', 'localhost')
|
|
32
|
+
env.setdefault('YHTTP_DB_DEFAULT_ADMINUSER', 'postgres')
|
|
33
|
+
env.setdefault('YHTTP_DB_DEFAULT_ADMINPASS', 'postgres')
|
|
34
|
+
|
|
35
|
+
with Given(cliapp, 'db', environ=env):
|
|
27
36
|
assert stderr == ''
|
|
28
37
|
assert status == 0
|
|
29
38
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
DBNAME = 'yhttp-postgesql-testing'
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def test_dbmanager(dbmanager):
|
|
5
|
+
# Cleanup
|
|
6
|
+
dbmanager.dropifexists(DBNAME)
|
|
7
|
+
|
|
8
|
+
assert dbmanager.exists('postgres')
|
|
9
|
+
assert not dbmanager.exists(DBNAME)
|
|
10
|
+
|
|
11
|
+
dbmanager.create(DBNAME)
|
|
12
|
+
assert dbmanager.exists(DBNAME)
|
|
13
|
+
|
|
14
|
+
dbmanager.create(DBNAME, dropifexists=True)
|
|
15
|
+
assert dbmanager.exists(DBNAME)
|
|
16
|
+
|
|
17
|
+
dbmanager.drop(DBNAME)
|
|
18
|
+
assert not dbmanager.exists(DBNAME)
|
|
19
|
+
|
|
20
|
+
dbmanager.create(DBNAME)
|
|
21
|
+
dbmanager.dropifexists(DBNAME)
|
|
22
|
+
assert not dbmanager.exists(DBNAME)
|
|
@@ -11,7 +11,7 @@ def test_dburi():
|
|
|
11
11
|
assert uri.user == 'bar'
|
|
12
12
|
assert uri.password == 'baz'
|
|
13
13
|
assert uri.host == 'qux'
|
|
14
|
-
assert uri.
|
|
14
|
+
assert uri.database == 'quux.thud'
|
|
15
15
|
assert uri.dumps() == uristr
|
|
16
16
|
|
|
17
17
|
# Invalid uri
|
|
@@ -26,7 +26,7 @@ def test_dburi():
|
|
|
26
26
|
assert uri.user == 'bar'
|
|
27
27
|
assert uri.password == ''
|
|
28
28
|
assert uri.host == 'qux'
|
|
29
|
-
assert uri.
|
|
29
|
+
assert uri.database == 'quux.thud'
|
|
30
30
|
assert uri.dumps() == uristr
|
|
31
31
|
|
|
32
32
|
# Without username and password
|
|
@@ -36,7 +36,7 @@ def test_dburi():
|
|
|
36
36
|
assert uri.user == ''
|
|
37
37
|
assert uri.password == ''
|
|
38
38
|
assert uri.host == 'qux'
|
|
39
|
-
assert uri.
|
|
39
|
+
assert uri.database == 'quux.thud'
|
|
40
40
|
assert uri.dumps() == uristr
|
|
41
41
|
|
|
42
42
|
# Without username, password and host
|
|
@@ -46,5 +46,18 @@ def test_dburi():
|
|
|
46
46
|
assert uri.user == ''
|
|
47
47
|
assert uri.password == ''
|
|
48
48
|
assert uri.host == ''
|
|
49
|
-
assert uri.
|
|
49
|
+
assert uri.database == 'quux.thud'
|
|
50
50
|
assert uri.dumps() == uristr
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def test_dburi_todict():
|
|
54
|
+
uristr = 'foo://bar:baz@qux/quux.thud'
|
|
55
|
+
uri = DatabaseURI.loads(uristr)
|
|
56
|
+
|
|
57
|
+
assert uri.todict() == dict(
|
|
58
|
+
provider='foo',
|
|
59
|
+
user='bar',
|
|
60
|
+
password='baz',
|
|
61
|
+
host='qux',
|
|
62
|
+
database='quux.thud'
|
|
63
|
+
)
|
|
@@ -50,7 +50,7 @@ class DatabaseAdministrativeCommand(SubCommand):
|
|
|
50
50
|
user=args.user,
|
|
51
51
|
password=password,
|
|
52
52
|
host=args.host,
|
|
53
|
-
|
|
53
|
+
database=args.database
|
|
54
54
|
)
|
|
55
55
|
|
|
56
56
|
def getappdbinfo(self, args):
|
|
@@ -65,7 +65,7 @@ class CreateDatabase(DatabaseAdministrativeCommand):
|
|
|
65
65
|
|
|
66
66
|
def __call__(self, args):
|
|
67
67
|
uri = self.getappdbinfo(args)
|
|
68
|
-
self.getdbmanager(args).create(uri.
|
|
68
|
+
self.getdbmanager(args).create(uri.database, owner=uri.user)
|
|
69
69
|
|
|
70
70
|
|
|
71
71
|
class DropDatabase(DatabaseAdministrativeCommand):
|
|
@@ -74,10 +74,10 @@ class DropDatabase(DatabaseAdministrativeCommand):
|
|
|
74
74
|
|
|
75
75
|
def __call__(self, args):
|
|
76
76
|
uri = self.getappdbinfo(args)
|
|
77
|
-
self.getdbmanager(args).drop(uri.
|
|
77
|
+
self.getdbmanager(args).drop(uri.database)
|
|
78
78
|
|
|
79
79
|
|
|
80
|
-
class
|
|
80
|
+
class DatabaseCommand(SubCommand):
|
|
81
81
|
__command__ = 'database'
|
|
82
82
|
__aliases__ = ['db']
|
|
83
83
|
__arguments__ = [
|
|
@@ -29,10 +29,11 @@ class DatabaseManager(metaclass=abc.ABCMeta):
|
|
|
29
29
|
|
|
30
30
|
class PostgresqlManager(DatabaseManager):
|
|
31
31
|
|
|
32
|
-
def __init__(self, host=None,
|
|
32
|
+
def __init__(self, host=None, database='postgres', user=None,
|
|
33
|
+
password=None):
|
|
33
34
|
self.connection = psycopg2.connect(
|
|
34
35
|
host=host,
|
|
35
|
-
dbname=
|
|
36
|
+
dbname=database,
|
|
36
37
|
user=user,
|
|
37
38
|
password=password
|
|
38
39
|
)
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
from .cli import
|
|
1
|
+
from .cli import DatabaseCommand
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
def install(app, cliarguments=None):
|
|
5
|
-
app.cliarguments.append(
|
|
5
|
+
app.cliarguments.append(DatabaseCommand)
|
|
6
6
|
if cliarguments:
|
|
7
|
-
|
|
7
|
+
DatabaseCommand.__arguments__.extend(cliarguments)
|
|
8
8
|
|
|
9
9
|
@app.when
|
|
10
10
|
def ready(app):
|
|
@@ -3,24 +3,24 @@ import re
|
|
|
3
3
|
|
|
4
4
|
URIPATTERN = re.compile(
|
|
5
5
|
r'(?P<provider>.*)://(?P<user>.*):(?P<password>.*)@(?P<host>.*)/'
|
|
6
|
-
r'(?P<
|
|
6
|
+
r'(?P<database>.*)'
|
|
7
7
|
)
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class DatabaseURI:
|
|
11
|
-
def __init__(self, provider,
|
|
11
|
+
def __init__(self, provider, database, host='', user='', password=''):
|
|
12
12
|
assert provider
|
|
13
|
-
assert
|
|
13
|
+
assert database
|
|
14
14
|
|
|
15
15
|
self.provider = provider
|
|
16
16
|
self.host = host
|
|
17
|
-
self.
|
|
17
|
+
self.database = database
|
|
18
18
|
self.user = user
|
|
19
19
|
self.password = password
|
|
20
20
|
|
|
21
21
|
def dumps(self):
|
|
22
22
|
return f'{self.provider}://{self.user}:{self.password}@{self.host}' \
|
|
23
|
-
f'/{self.
|
|
23
|
+
f'/{self.database}'
|
|
24
24
|
|
|
25
25
|
@classmethod
|
|
26
26
|
def loads(cls, uri):
|
|
@@ -31,11 +31,20 @@ class DatabaseURI:
|
|
|
31
31
|
u = match.groupdict()
|
|
32
32
|
|
|
33
33
|
assert u.get('provider')
|
|
34
|
-
assert u.get('
|
|
34
|
+
assert u.get('database')
|
|
35
35
|
return cls(
|
|
36
36
|
u.get('provider'),
|
|
37
|
-
u.get('
|
|
37
|
+
u.get('database'),
|
|
38
38
|
u.get('host'),
|
|
39
39
|
u.get('user'),
|
|
40
40
|
u.get('password'),
|
|
41
41
|
)
|
|
42
|
+
|
|
43
|
+
def todict(self):
|
|
44
|
+
return dict(
|
|
45
|
+
provider=self.provider,
|
|
46
|
+
user=self.user,
|
|
47
|
+
password=self.password,
|
|
48
|
+
host=self.host,
|
|
49
|
+
database=self.database
|
|
50
|
+
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: yhttp-dbmanager
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0.2
|
|
4
4
|
Summary: Database manager command line interface and API for yhttp.
|
|
5
5
|
Home-page: http://github.com/yhttp/yhttp-dbmanager
|
|
6
6
|
Author: Vahid Mardani
|
|
@@ -22,7 +22,7 @@ Classifier: Topic :: Software Development :: Libraries
|
|
|
22
22
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
23
|
Description-Content-Type: text/markdown
|
|
24
24
|
License-File: LICENSE
|
|
25
|
-
Requires-Dist: yhttp<
|
|
25
|
+
Requires-Dist: yhttp<6,>=5
|
|
26
26
|
Requires-Dist: psycopg2
|
|
27
27
|
|
|
28
28
|
# yhttp-dbmanager
|
|
@@ -33,7 +33,7 @@ API.
|
|
|
33
33
|
## Contribution
|
|
34
34
|
|
|
35
35
|
### Dependencies
|
|
36
|
-
Install `
|
|
36
|
+
Install `postgresql` brefore use of this project.
|
|
37
37
|
```bash
|
|
38
38
|
apt install postgresql
|
|
39
39
|
```
|
|
@@ -82,12 +82,17 @@ make test
|
|
|
82
82
|
|
|
83
83
|
Execute specific test(s) using wildcard:
|
|
84
84
|
```bash
|
|
85
|
-
make test
|
|
85
|
+
make test F=tests/test_db*
|
|
86
|
+
make test F=tests/test_form.py::test_querystringform
|
|
86
87
|
```
|
|
87
88
|
|
|
88
|
-
|
|
89
|
+
*refer to* [pytest documentation](https://docs.pytest.org/en/7.1.x/how-to/usage.html#how-to-invoke-pytest)
|
|
90
|
+
*for more info about invoking tests.*
|
|
91
|
+
|
|
92
|
+
Execute tests and report coverage result:
|
|
89
93
|
```bash
|
|
90
94
|
make cover
|
|
95
|
+
make cover F=tests/test_static.py
|
|
91
96
|
make cover-html
|
|
92
97
|
```
|
|
93
98
|
|
|
@@ -118,7 +123,7 @@ Execute:
|
|
|
118
123
|
```bash
|
|
119
124
|
make clean
|
|
120
125
|
```
|
|
121
|
-
to clean-up previous dist
|
|
126
|
+
to clean-up previous `dist/*` and `build/*` directories.
|
|
122
127
|
|
|
123
128
|
|
|
124
129
|
### PyPI
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
from yhttp.ext.dbmanager import PostgresqlManager
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
DBNAME = 'yhttp-postgesql-testing'
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def test_dbmanager():
|
|
8
|
-
# Instance with postgres identity framework.
|
|
9
|
-
dbm = PostgresqlManager()
|
|
10
|
-
|
|
11
|
-
# Cleanup
|
|
12
|
-
dbm.dropifexists(DBNAME)
|
|
13
|
-
|
|
14
|
-
assert dbm.exists('postgres')
|
|
15
|
-
assert not dbm.exists(DBNAME)
|
|
16
|
-
|
|
17
|
-
dbm.create(DBNAME)
|
|
18
|
-
assert dbm.exists(DBNAME)
|
|
19
|
-
|
|
20
|
-
dbm.create(DBNAME, dropifexists=True)
|
|
21
|
-
assert dbm.exists(DBNAME)
|
|
22
|
-
|
|
23
|
-
dbm.drop(DBNAME)
|
|
24
|
-
assert not dbm.exists(DBNAME)
|
|
25
|
-
|
|
26
|
-
dbm.create(DBNAME)
|
|
27
|
-
dbm.dropifexists(DBNAME)
|
|
28
|
-
assert not dbm.exists(DBNAME)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.2}/yhttp_dbmanager.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|