Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
persisting-theory
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Eliot Berriot
persisting-theory
Commits
fa5ca1ec
Commit
fa5ca1ec
authored
Oct 13, 2014
by
Eliot Berriot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tox and refactored tests
parent
3c100135
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
50 additions
and
27 deletions
+50
-27
persisting_theory/__init__.py
persisting_theory/__init__.py
+1
-1
persisting_theory/tests/buggy_app/__init__.py
persisting_theory/tests/buggy_app/__init__.py
+0
-0
persisting_theory/tests/buggy_app/awesome_people.py
persisting_theory/tests/buggy_app/awesome_people.py
+0
-3
setup.py
setup.py
+3
-3
tests/__init__.py
tests/__init__.py
+7
-0
tests/app1/__init__.py
tests/app1/__init__.py
+0
-0
tests/app1/awesome_people.py
tests/app1/awesome_people.py
+1
-1
tests/app1/vegetables.py
tests/app1/vegetables.py
+1
-1
tests/app2/__init__.py
tests/app2/__init__.py
+0
-0
tests/app2/awesome_people.py
tests/app2/awesome_people.py
+5
-0
tests/app2/vegetables.py
tests/app2/vegetables.py
+5
-0
tests/buggy_app/__init__.py
tests/buggy_app/__init__.py
+0
-0
tests/buggy_app/awesome_people.py
tests/buggy_app/awesome_people.py
+3
-0
tests/test_registries.py
tests/test_registries.py
+1
-1
tests/tests.py
tests/tests.py
+16
-17
tox.ini
tox.ini
+7
-0
No files found.
persisting_theory/__init__.py
View file @
fa5ca1ec
from
registries
import
Registry
,
meta_registry
from
.
registries
import
Registry
,
meta_registry
__version__
=
"0.2.0"
\ No newline at end of file
persisting_theory/tests/buggy_app/__init__.py
deleted
100644 → 0
View file @
3c100135
persisting_theory/tests/buggy_app/awesome_people.py
deleted
100644 → 0
View file @
3c100135
from
test_registries
import
awesome_people
print
(
inexisting_var
)
\ No newline at end of file
setup.py
View file @
fa5ca1ec
import
os
from
setuptools
import
setup
,
find_packages
import
persisting_theory
import
persisting_theory
as
package
README
=
open
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'README.rst'
))
.
read
()
...
...
@@ -9,11 +9,11 @@ os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))
setup
(
name
=
'persisting-theory'
,
version
=
p
ersisting_theory
.
__version__
,
version
=
p
ackage
.
__version__
,
packages
=
find_packages
(),
include_package_data
=
True
,
license
=
'BSD'
,
# example license
description
=
'
A python package to build registries that can autodiscover values accross your project component
s'
,
description
=
'
Registries that can autodiscover values accross your project app
s'
,
long_description
=
README
,
url
=
'http://code.eliotberriot.com/eliotberriot/persisting-theory'
,
author
=
'Eliot Berriot'
,
...
...
tests/__init__.py
0 → 100644
View file @
fa5ca1ec
import
os
,
sys
TEST_DIR
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
BASE_DIR
=
os
.
path
.
dirname
(
TEST_DIR
)
sys
.
path
.
append
(
BASE_DIR
)
\ No newline at end of file
persisting_theory/tests
/__init__.py
→
tests/app1
/__init__.py
View file @
fa5ca1ec
File moved
persisting_theory/
tests/app1/awesome_people.py
→
tests/app1/awesome_people.py
View file @
fa5ca1ec
from
test_registries
import
awesome_people
from
..
test_registries
import
awesome_people
@
awesome_people
.
register
class
AlainDamasio
:
...
...
persisting_theory/
tests/app1/vegetables.py
→
tests/app1/vegetables.py
View file @
fa5ca1ec
from
test_registries
import
vegetable_registry
from
..
test_registries
import
vegetable_registry
@
vegetable_registry
.
register
class
Potato
:
...
...
persisting_theory/tests/app1
/__init__.py
→
tests/app2
/__init__.py
View file @
fa5ca1ec
File moved
persisting_theory/
tests/app2/awesome_people.py
→
tests/app2/awesome_people.py
View file @
fa5ca1ec
from
test_registries
import
awesome_people
from
..
test_registries
import
awesome_people
@
awesome_people
.
register
class
FrederikPeeters
:
...
...
persisting_theory/
tests/app2/vegetables.py
→
tests/app2/vegetables.py
View file @
fa5ca1ec
from
test_registries
import
vegetable_registry
from
..
test_registries
import
vegetable_registry
@
vegetable_registry
.
register
class
Ketchup
:
...
...
persisting_theory/tests/app2
/__init__.py
→
tests/buggy_app
/__init__.py
View file @
fa5ca1ec
File moved
tests/buggy_app/awesome_people.py
0 → 100644
View file @
fa5ca1ec
from
..test_registries
import
awesome_people
print
(
inexisting_var
)
\ No newline at end of file
persisting_theory/
tests/test_registries.py
→
tests/test_registries.py
View file @
fa5ca1ec
from
registries
import
Registry
,
meta_registry
from
persisting_theory
import
Registry
,
meta_registry
class
AwesomePeopleRegistry
(
Registry
):
look_into
=
"awesome_people"
...
...
persisting_theory/
tests/tests.py
→
tests/tests.py
View file @
fa5ca1ec
import
os
,
sys
sys
.
path
.
append
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
__file__
)))
import
unittest
import
test_registries
import
registries
from
.
import
test_registries
import
persisting_theory
registries
.
meta_registry
.
look_into
=
"test_registries"
persisting_theory
.
meta_registry
.
look_into
=
"test_registries"
TEST_APPS
=
(
"app1"
,
"app2"
,
"
tests.
app1"
,
"
tests.
app2"
,
)
class
RegistryTest
(
unittest
.
TestCase
):
def
test_can_infer_name_from_class_function_and_instance
(
self
):
registry
=
registries
.
Registry
()
registry
=
persisting_theory
.
Registry
()
def
something
():
pass
...
...
@@ -31,7 +30,7 @@ class RegistryTest(unittest.TestCase):
def
test_can_register_data_to_registry
(
self
):
data
=
"something"
registry
=
registries
.
Registry
()
registry
=
persisting_theory
.
Registry
()
registry
.
register
(
data
,
name
=
"key"
)
self
.
assertEqual
(
len
(
registry
),
1
)
...
...
@@ -39,7 +38,7 @@ class RegistryTest(unittest.TestCase):
def
test_can_restric_registered_data
(
self
):
class
RestrictedRegistry
(
registries
.
Registry
):
class
RestrictedRegistry
(
persisting_theory
.
Registry
):
def
validate
(
self
,
obj
):
"""Only accept integer values"""
return
isinstance
(
obj
,
int
)
...
...
@@ -52,7 +51,7 @@ class RegistryTest(unittest.TestCase):
def
test_can_register_class_and_function_via_decorator
(
self
):
registry
=
registries
.
Registry
()
registry
=
persisting_theory
.
Registry
()
@
registry
.
register
class
ToRegister
:
...
...
@@ -67,7 +66,7 @@ class RegistryTest(unittest.TestCase):
self
.
assertEqual
(
registry
.
get
(
'something'
),
something
)
def
test_can_register_via_decorator_using_custom_name
(
self
):
registry
=
registries
.
Registry
()
registry
=
persisting_theory
.
Registry
()
@
registry
.
register
(
name
=
"custom_name"
)
def
something
():
...
...
@@ -89,11 +88,11 @@ class RegistryTest(unittest.TestCase):
def
test_autodiscover_raises_an_error_if_there_is_an_error_in_imported_module
(
self
):
with
self
.
assertRaises
(
NameError
):
registry
=
test_registries
.
awesome_people
registry
.
autodiscover
(
apps
=
(
'buggy_app'
,))
registry
.
autodiscover
(
apps
=
(
'
tests.
buggy_app'
,))
def
test_meta_registry_can_autodiscovering_registries_and_trigger_their_autodiscover_method
(
self
):
registry
=
registries
.
meta_registry
registry
=
persisting_theory
.
meta_registry
registry
.
autodiscover
(
apps
=
TEST_APPS
)
self
.
assertEqual
(
len
(
registry
),
2
)
...
...
@@ -112,7 +111,7 @@ class RegistryTest(unittest.TestCase):
def
test_can_manipulate_data_before_registering
(
self
):
class
ModifyData
(
registries
.
Registry
):
class
ModifyData
(
persisting_theory
.
Registry
):
def
prepare_data
(
self
,
data
):
return
"hello "
+
data
...
...
@@ -126,7 +125,7 @@ class RegistryTest(unittest.TestCase):
def
test_can_manipulate_key_before_registering
(
self
):
class
ModifyKey
(
registries
.
Registry
):
class
ModifyKey
(
persisting_theory
.
Registry
):
def
prepare_name
(
self
,
data
,
key
=
None
):
return
"custom_key "
+
data
.
first_name
...
...
@@ -149,7 +148,7 @@ class RegistryTest(unittest.TestCase):
class
PostRegisterException
(
Exception
):
pass
class
PostRegister
(
registries
.
Registry
):
class
PostRegister
(
persisting_theory
.
Registry
):
def
post_register
(
self
,
data
,
name
):
raise
PostRegisterException
(
'Post register triggered'
)
...
...
tox.ini
0 → 100644
View file @
fa5ca1ec
[tox]
envlist
=
py27,py34
skipsdist
=
True
[testenv]
deps
=
nose
commands
=
nosetests
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment