Skip to content

Commit

Permalink
Adds dexterity types and basic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
href committed Sep 30, 2014
1 parent 5c0189a commit 4e87575
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 2 deletions.
2 changes: 2 additions & 0 deletions seantis/placemap/content/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .map import Map
from .source import Source
5 changes: 5 additions & 0 deletions seantis/placemap/content/map.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from plone.dexterity.content import Container


class Map(Container):
pass
5 changes: 5 additions & 0 deletions seantis/placemap/content/source.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from plone.dexterity.content import Container


class Source(Container):
pass
4 changes: 2 additions & 2 deletions seantis/placemap/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ISeantisPlacemapSpecific(Interface):
pass


class IPlacemap(form.Schema):
class IMap(form.Schema):
""" Contains the urls to the kml documents. """

title = schema.TextLine(
Expand All @@ -19,7 +19,7 @@ class IPlacemap(form.Schema):
)


class IPlacemapSource(form.Schema):
class ISource(form.Schema):
""" Defines the source of a kml document and describes features like
the icon to use for placemarks or the color to use for lines.
Expand Down
4 changes: 4 additions & 0 deletions seantis/placemap/profiles/default/types.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<object name="portal_types">
<object name="seantis.placemap.map" meta_type="Dexterity FTI" />
<object name="seantis.placemap.source" meta_type="Dexterity FTI" />
</object>
29 changes: 29 additions & 0 deletions seantis/placemap/profiles/default/types/seantis.placemap.map.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<object name="seantis.placemap.list" meta_type="Dexterity FTI"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
i18n:domain="seantis.placemap">

<!-- Basic metadata -->
<property name="title" i18n:translate="">Placemap</property>
<property name="icon_expr">string:${portal_url}/folder_icon.png</property>
<property name="global_allow">True</property>
<property name="filter_content_types">False</property>
<property name="allowed_content_types">
<element value="seantis.placemap.source" />
</property>

<!-- schema interface -->
<property name="schema">seantis.placemap.interfaces.IMap</property>

<!-- class used for content items -->
<property name="klass">seantis.placemap.content.Map</property>

<!-- add permission -->
<property name="add_permission">cmf.AddPortalContent</property>

<!-- enabled behaviors -->
<property name="behaviors">
<element value="plone.app.content.interfaces.INameFromTitle" />
</property>

</object>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<object name="seantis.placemap.list" meta_type="Dexterity FTI"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
i18n:domain="seantis.placemap">

<!-- Basic metadata -->
<property name="title" i18n:translate="">Placemap Source</property>
<property name="icon_expr">string:${portal_url}/file_icon.png</property>
<property name="global_allow">True</property>
<property name="filter_content_types">False</property>
<property name="allowed_content_types">
<element value="seantis.placemap.source" />
</property>

<!-- schema interface -->
<property name="schema">seantis.placemap.interfaces.ISource</property>

<!-- class used for content items -->
<property name="klass">seantis.placemap.content.Source</property>

<!-- add permission -->
<property name="add_permission">cmf.AddPortalContent</property>

<!-- enabled behaviors -->
<property name="behaviors">
<element value="plone.app.content.interfaces.INameFromTitle" />
</property>

</object>
20 changes: 20 additions & 0 deletions seantis/placemap/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from plone import api
from uuid import uuid4
from zope.security.management import newInteraction, endInteraction

from seantis.plonetools.testing import TestCase
Expand All @@ -19,6 +21,24 @@ def tearDown(self):
endInteraction()
super(IntegrationTestCase, self).tearDown()

def create_map(self, **kwargs):
with self.user('admin'):
return api.content.create(
id=uuid4().hex,
type='seantis.placemap.map',
container=self.new_temporary_folder(),
**kwargs
)

def create_source(self, map, **kwargs):
with self.user('admin'):
return api.content.create(
id=uuid4().hex,
type='seantis.placemap.source',
container=map,
**kwargs
)


# to use with the browser which does its own security interactions
class FunctionalTestCase(TestCase):
Expand Down
12 changes: 12 additions & 0 deletions seantis/placemap/tests/test_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from seantis.placemap import tests
from seantis.placemap import content


class TestTypes(tests.IntegrationTestCase):

def test_create_types(self):
map = self.create_map()
self.assertIs(type(map.aq_base), content.Map)

source = self.create_source(map)
self.assertIs(type(source.aq_base), content.Source)

0 comments on commit 4e87575

Please sign in to comment.