Compare commits
15 commits
Author | SHA1 | Date | |
---|---|---|---|
2f13094bbb | |||
b85425df6f | |||
3b2b25226d | |||
bf617e12b0 | |||
e8f51cb41a | |||
573d4f0198 | |||
f100a18f22 | |||
bf2d8a1e99 | |||
f66ef8ee5c | |||
06098265d1 | |||
cbbc8a3b87 | |||
0fb0ba0c74 | |||
0985f1b886 | |||
ec99c62348 | |||
71fc565a7e |
11 changed files with 65 additions and 188 deletions
|
@ -1,20 +0,0 @@
|
|||
# py-scopes/demo/config.py
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from os import getenv
|
||||
from scopes.server.app import zope_app_factory
|
||||
|
||||
load_dotenv()
|
||||
|
||||
server_port = getenv('SERVER_PORT', '8099')
|
||||
|
||||
app_factory = zope_app_factory
|
||||
|
||||
# storage settings
|
||||
from scopes.storage.db.postgres import StorageFactory
|
||||
dbengine = 'postgresql+psycopg'
|
||||
dbname = getenv('DBNAME', 'demo')
|
||||
dbuser = getenv('DBUSER', 'demo')
|
||||
dbpassword = getenv('DBPASSWORD', 'secret')
|
||||
dbschema = getenv('DBSCHEMA', 'demo')
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
# py-scopes/demo/demo_server.py
|
||||
|
||||
from wsgiref.simple_server import make_server
|
||||
|
||||
def run(app, config):
|
||||
port = int(config.server_port)
|
||||
with make_server('', port, app) as httpd:
|
||||
print(f'Serving on port {port}.')
|
||||
try:
|
||||
httpd.serve_forever()
|
||||
except KeyboardInterrupt:
|
||||
print('Shutting down.')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import config
|
||||
#run(config.app, config)
|
||||
app = config.app_factory(config)
|
||||
run(app, config)
|
||||
# see zope.app.wsgi.getWSGIApplication
|
|
@ -1,34 +0,0 @@
|
|||
[build-system]
|
||||
requires = ["setuptools"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "py-scopes"
|
||||
version = "3.0.1"
|
||||
description = "Implementation of the unknown 'scopes' paradigm in Python"
|
||||
readme = "README.md"
|
||||
license = {text = "MIT"}
|
||||
keywords = ["scopes"]
|
||||
authors = [{name = "Helmut Merz", email = "helmutm@cy55.de"}]
|
||||
|
||||
dependencies = [
|
||||
"SQLAlchemy",
|
||||
]
|
||||
|
||||
[project.optional-dependencies]
|
||||
postgres = [
|
||||
"psycopg[binary]",
|
||||
"transaction",
|
||||
"zope.sqlalchemy",
|
||||
]
|
||||
app = ["python-dotenv", "zope.publisher", "zope.traversing"]
|
||||
test = ["pytest"]
|
||||
|
||||
[tool.setuptools]
|
||||
packages = ["scopes"]
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
addopts = "-vv"
|
||||
python_files = "test_standard.py" # default: run only `standard` tests
|
||||
# use .pytest.ini file with `python_files = test_*.py` to run all tests
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
|
||||
python tests/test_postgres.py
|
||||
python tests/test_standard.py
|
|
@ -20,8 +20,7 @@ class Track(object):
|
|||
headFields = ['taskId', 'userName']
|
||||
prefix = 'rec'
|
||||
|
||||
def __init__(self, *keys, data=None, timeStamp=None, trackId=None,
|
||||
container=None, **kw):
|
||||
def __init__(self, *keys, **kw):
|
||||
self.head = {}
|
||||
for k, v in kw.items():
|
||||
if k in self.headFields:
|
||||
|
@ -32,10 +31,10 @@ class Track(object):
|
|||
if self.head.get(k) is None:
|
||||
self.head[k] = ''
|
||||
setattr(self, k, self.head[k])
|
||||
self.data = data or {}
|
||||
self.timeStamp = timeStamp
|
||||
self.trackId = trackId
|
||||
self.container = container
|
||||
self.data = kw.get('data') or {}
|
||||
self.timeStamp = kw.get('timeStamp')
|
||||
self.trackId = kw.get('trackId')
|
||||
self.container = kw.get('container')
|
||||
|
||||
def set(self, attr, value):
|
||||
if attr in self.headFields:
|
||||
|
|
|
@ -1,38 +1,33 @@
|
|||
#! /usr/bin/python
|
||||
# scopes/tests.py
|
||||
|
||||
"""Tests for the 'scopes.storage' package - using PostgreSQL."""
|
||||
"""The real test implementations"""
|
||||
|
||||
import unittest
|
||||
import tlib_storage
|
||||
from scopes import tlib_storage
|
||||
|
||||
from scopes.storage.db.postgres import StorageFactory
|
||||
import config
|
||||
config.dbengine = 'postgresql+psycopg'
|
||||
config.dbname = 'testdb'
|
||||
config.dbuser = 'testuser'
|
||||
config.dbpassword = 'secret'
|
||||
config.dbengine = 'postgresql'
|
||||
config.dbname = 'ccotest'
|
||||
config.dbuser = 'ccotest'
|
||||
config.dbpassword = 'cco'
|
||||
config.dbschema = 'testing'
|
||||
|
||||
# PostgreSQL-specific settings
|
||||
from scopes.storage.db.postgres import StorageFactory
|
||||
config.storageFactory = StorageFactory(config)
|
||||
#storage = factory(schema='testing')
|
||||
|
||||
|
||||
class Test(unittest.TestCase):
|
||||
|
||||
def test_001_tracking(self):
|
||||
tlib_storage.test_tracking(self, config)
|
||||
|
||||
|
||||
def test_002_folder(self):
|
||||
tlib_storage.test_folder(self, config)
|
||||
|
||||
|
||||
def test_003_type(self):
|
||||
tlib_storage.test_type(self, config)
|
||||
|
||||
|
||||
def test_004_topic(self):
|
||||
tlib_storage.test_topic(self, config)
|
||||
|
||||
def suite():
|
||||
return unittest.TestSuite((
|
||||
unittest.TestLoader().loadTestsFromTestCase(Test),
|
||||
))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(defaultTest='suite')
|
|
@ -1,4 +1,4 @@
|
|||
# tests/tlib_storage.py
|
||||
# scopes/tlib_storage.py
|
||||
|
||||
"""Test implementation for the `scopes.storage` package."""
|
||||
|
47
setup.py
47
setup.py
|
@ -1,4 +1,47 @@
|
|||
from setuptools import setup
|
||||
from setuptools import setup, find_packages
|
||||
import os
|
||||
|
||||
setup()
|
||||
version = '2.0'
|
||||
|
||||
long_description = (
|
||||
open('README.md').read()
|
||||
+ '\n' +
|
||||
'Contributors\n'
|
||||
'============\n'
|
||||
+ '\n' +
|
||||
open('CONTRIBUTORS.txt').read()
|
||||
+ '\n' +
|
||||
open('CHANGES.txt').read()
|
||||
+ '\n')
|
||||
|
||||
setup(name='py-scopes',
|
||||
version=version,
|
||||
description="combined triple and event storage for the cco application platform",
|
||||
long_description=long_description,
|
||||
# Get more strings from
|
||||
# http://pypi.python.org/pypi?%3Aaction=list_classifiers
|
||||
classifiers=[
|
||||
"Programming Language :: Python",
|
||||
],
|
||||
keywords='',
|
||||
author='cyberconcepts.org team',
|
||||
author_email='team@cyberconcepts.org',
|
||||
url='http://www.cyberconcepts.org',
|
||||
license='MIT',
|
||||
packages=find_packages(),
|
||||
#package_dir = {'': 'src'},
|
||||
#namespace_packages=['cco'],
|
||||
include_package_data=True,
|
||||
zip_safe=False,
|
||||
install_requires=[
|
||||
'setuptools',
|
||||
'transaction',
|
||||
'psycopg2-binary',
|
||||
'SQLAlchemy',
|
||||
'zope.sqlalchemy',
|
||||
# -*- Extra requirements: -*-
|
||||
],
|
||||
entry_points="""
|
||||
# -*- Entry points: -*-
|
||||
""",
|
||||
)
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
# py-scopes/tests/config.py
|
||||
|
||||
#from scopes.server.app import demo_app, zope_app
|
||||
|
||||
# server / app settings
|
||||
server_port = '8999'
|
||||
#app = zope_app
|
||||
|
||||
# storage settings
|
||||
|
||||
# SQLite
|
||||
dbengine = 'sqlite'
|
||||
dbname = 'var/test.db'
|
||||
dbuser = None
|
||||
dbpassword = None
|
||||
dbschema = None
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
"""Tests for the 'scopes.storage' package."""
|
||||
|
||||
import unittest
|
||||
import tlib_server, tlib_storage
|
||||
|
||||
from scopes.storage.common import StorageFactory
|
||||
import config
|
||||
config.dbengine = 'sqlite'
|
||||
config.dbname = 'var/test.db'
|
||||
config.dbschema = None
|
||||
config.storageFactory = StorageFactory(config)
|
||||
|
||||
|
||||
class Test(unittest.TestCase):
|
||||
|
||||
def test_001_tracking(self):
|
||||
tlib_storage.test_tracking(self, config)
|
||||
|
||||
def test_002_folder(self):
|
||||
tlib_storage.test_folder(self, config)
|
||||
|
||||
def test_003_type(self):
|
||||
tlib_storage.test_type(self, config)
|
||||
|
||||
def test_004_topic(self):
|
||||
tlib_storage.test_topic(self, config)
|
||||
|
||||
def test_013_server(self):
|
||||
tlib_server.test_app(self, config)
|
||||
|
||||
|
||||
def suite():
|
||||
return unittest.TestSuite((
|
||||
unittest.TestLoader().loadTestsFromTestCase(Test),
|
||||
))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(defaultTest='suite')
|
|
@ -1,26 +0,0 @@
|
|||
# tests/tlib_server.py
|
||||
|
||||
"""Test implementation for the `scopes.server` package."""
|
||||
|
||||
import json
|
||||
from zope.publisher.browser import TestRequest
|
||||
from zope.publisher.publish import publish
|
||||
|
||||
from scopes.server.app import Publication
|
||||
from scopes.storage.folder import Root
|
||||
|
||||
|
||||
def publishRequest(config, storage, path):
|
||||
appRoot = Root(storage)
|
||||
request = TestRequest(environ=dict(PATH_INFO=path))
|
||||
request.setPublication(Publication(appRoot))
|
||||
request = publish(request, False)
|
||||
return request.response
|
||||
|
||||
|
||||
def test_app(self, config):
|
||||
storage = config.storageFactory(config.dbschema)
|
||||
response = publishRequest(config, storage, '/top')
|
||||
result = json.loads(response.consumeBody())
|
||||
self.assertEqual(result['items'][0]['head']['name'], 'level2-item1')
|
||||
|
Loading…
Add table
Reference in a new issue