desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'GIS / GIS Controllers'
| def gis(self):
| if (current.request.function == 'index'):
return None
else:
return super(S3OptionsMenu, self).gis()
|
'Person Registry'
| def pr(self):
| if (current.request.function == 'person'):
return self.hrm()
else:
return super(S3OptionsMenu, self).pr()
|
'HRM Human Talent'
| @staticmethod
def hrm():
| request = current.request
if ('profile' in request.get_vars):
return
auth = current.auth
has_role = auth.s3_has_role
s3 = current.session.s3
len_roles = len(s3.roles)
if ((len_roles <= 2) or ((len_roles == 3) and has_role('RIT_MEMBER') and (not has_role('ADMIN')))):
return
... |
'Organisation Management'
| def org(self):
| return self.hrm()
|
'INV / Inventory'
| @staticmethod
def inv():
| has_role = current.auth.s3_has_role
system_roles = current.session.s3.system_roles
ADMIN = system_roles.ADMIN
ORG_ADMIN = system_roles.ORG_ADMIN
s3db = current.s3db
s3db.inv_recv_crud_strings()
inv_recv_list = current.response.s3.crud_strings.inv_recv.title_list
settings = current.deploy... |
'Requests Management'
| def req(self):
| return self.inv()
|
'PROJECT / Project Tracking & Management'
| @staticmethod
def project():
| system_roles = current.session.s3.system_roles
ORG_ADMIN = system_roles.ORG_ADMIN
menu = M(c='project')(M('Programs', f='programme')(M('Create', m='create')), M('Projects', f='project', m='summary')(M('Create', m='create')), M('Locations', f='location')(M('Map', m='map'), M('Community Contacts', f='locat... |
'RIT Alerting and Deployments'
| @staticmethod
def deploy():
| return M()(M('Missions', c='deploy', f='mission', m='summary')(M('Create', m='create'), M('Active Missions', m='summary', vars={'~.status__belongs': '2'})), M('Alerts', c='deploy', f='alert')(M('Create', m='create'), M('Twitter Settings', c='deploy', f='twitter_channel', p='update', t='msg_twitter_channel')),... |
'Custom Layout Method'
| @staticmethod
def layout(item):
| if (not item.authorized):
item.enabled = False
item.visible = False
elif ((item.enabled is None) or item.enabled):
item.enabled = True
item.visible = True
if (item.enabled and item.visible):
items = item.render_components()
if (item.parent is not None):
... |
'Render special active items'
| @staticmethod
def checkbox_item(item):
| name = item.label
link = item.url()
_id = name['id']
if ('name' in name):
_name = name['name']
else:
_name = ''
if ('value' in name):
_value = name['value']
else:
_value = False
if ('request_type' in name):
_request_type = name['request_type']
... |
'Language menu layout
options for each entry:
- lang_code: the language code
- lang_name: the language name
option for the menu
- current_language: code of the current language'
| @staticmethod
def layout(item):
| if item.enabled:
if item.components:
current_language = current.T.accepted_language
items = item.render_components()
select = SELECT(items, value=current_language, _name='_language', _title='Language Selection', _onchange="S3.reloadWithQueryStringVars({'_language':$(th... |
'Check whether the language menu is enabled'
| def check_enabled(self):
| if current.deployment_settings.get_L10n_display_toolbar():
return True
else:
return False
|
'@ToDo: Migrate to s3db.org_logo_represent'
| @staticmethod
def layout(item):
| name = 'IFRC'
logo = None
root_org = current.auth.root_org()
if root_org:
db = current.db
s3db = current.s3db
language = current.session.s3.language
if (language == current.deployment_settings.get_L10n_default_language()):
l10n = None
else:
... |
'@param: client_config (optional) passes configuration dict
through to the client-side map plugin.'
| def __init__(self, env, year_min, year_max, place_table, client_config={}):
| try:
import rpy2
import rpy2.robjects as robjects
except ImportError:
import logging
logging.getLogger().error('R is required by the climate data portal to generate charts\n\n To install R: refer to:\n ... |
'Writes the average reading to the database for that place and month'
| def done(self):
| for (day_number, values) in self.aggregated_values.iteritems():
self.sample_table.insert(time_period=month_number, place_id=self.place_id, value=(sum(values) / len(values)))
|
'format example: m Kg^2 / s^2'
| @staticmethod
def parsed_from(unit_string, positive=None):
| if (positive is None):
positive = True
for delta_string in Units.delta_strings:
if unit_string.startswith(delta_string):
unit_string = unit_string[len(delta_string):]
positive = False
break
dimensions = {}
for (factor, dimension_cou... |
'Example:
>>> c = Counter({"a": 4, "b": 2})'
| def __init__(units, dimensions, positive):
| for (dimension, count) in dimensions.iteritems():
if (not isinstance(count, int)):
raise DimensionError(('%s dimension count must be a whole number' % dimension))
units._dimensions = dimensions.copy()
units._positive = bool(positive)
|
'call a method on the remote server'
| def __request(self, methodname, params):
| request = dumps(params, methodname, encoding=self.__encoding, allow_none=self.__allow_none)
response = self.__transport.request(self.__host, self.__handler, request, verbose=self.__verbose)
if (len(response) == 1):
response = response[0]
return response
|
'Creates a new instance of the PhantomJS / Ghostdriver.
Starts the service and then creates new instance of the driver.
:Args:
- executable_path - path to the executable. If the default is used it assumes the executable is in the $PATH
- port - port you would like the service to run, if left as 0, a free port will be f... | def __init__(self, executable_path='phantomjs', port=0, desired_capabilities=DesiredCapabilities.PHANTOMJS, service_args=None, service_log_path=None):
| self.service = Service(executable_path, port=port, service_args=service_args, log_path=service_log_path)
self.service.start()
command_executor = self.service.service_url
try:
RemoteWebDriver.__init__(self, command_executor=command_executor, desired_capabilities=desired_capabilities)
except:
... |
'Closes the browser and shuts down the PhantomJS executable
that is started when starting the PhantomJS'
| def quit(self):
| try:
RemoteWebDriver.quit(self)
except:
pass
finally:
self.service.stop()
|
'Synchronously Executes JavaScript in the PhantomJS context.
This allows access to advanced features like clipRect.
:Args:
- script: The JavaScript to execute.
- \*args: Any applicable arguments for your JavaScript.
:Usage:
driver.execute_phantomjs(\'\')'
| def execute_phantomjs(self, script, *args):
| converted_args = list(args)
return self.execute(Command.EXECUTE_PHANTOM_SCRIPT, {'script': script, 'args': converted_args})['value']
|
'Setup all plugins
@param reload_all: reload all plugins and reset the registry'
| @classmethod
def setup_all(cls, reload_all=False):
| if reload_all:
cls.detect(reset_all=True)
for name in cls._registry().keys():
cls.load(name)
|
'Detect new plugins and update the registry
@param reset_all: reset all entries in the registry'
| @classmethod
def detect(cls, reset_all=False):
| default = (None, None)
if reset_all:
plugin = (lambda name: default)
else:
registry = cls._registry()
plugin = (lambda name: registry.get(name, default))
plugins = dict(((name, plugin(name)) for name in cls._scan()))
cls._registry(plugins)
|
'Run the setup method of a particular plugin
@param name: the name of the plugin
@param force: enforce the plugin to be reloaded and its
setup method to be re-run regardless of the
previous status'
| @classmethod
def load(cls, name, force=False):
| log = current.log
registry = cls._registry()
if (name not in registry):
cls.detect()
if (name not in registry):
raise NameError(("plugin '%s' not found" % name))
plugin_info = registry[name]
if (force or (not isinstance(plugin_info, tuple))):
(version, status) = ... |
'Get (or replace) the current plugin registry
@param plugins: the new registry'
| @classmethod
def _registry(cls, plugins=None):
| session_s3 = current.session.s3
if plugins:
registry = session_s3.plugins = plugins
else:
registry = session_s3.plugins
if (registry is None):
registry = session_s3.plugins = {}
cls.detect()
return registry
|
'Iterator scanning the plugin directory for available plugins
@return: the names of the plugins'
| @staticmethod
def _scan():
| folder = current.request.folder
path = os.path.join(folder, 'modules', PLUGINS)
names = os.listdir(path)
for name in names:
(name_, extension) = os.path.splitext(name)
if (name_ in IGNORE):
continue
path_ = os.path.join(path, name)
if (os.path.isdir(path_) or ... |
'Reload a plugin
@param name: the plugin name
@note: this works only within the current thread, other
threads may still be bound to the old version of
the plugin'
| @staticmethod
def _reload(name):
| if (name in IGNORE):
return
success = True
appname = current.request.application
plugin_name = ('applications.%s.modules.%s.%s' % (appname, PLUGINS, name))
plugin = sys.modules.get(plugin_name)
if (plugin is not None):
try:
reload(plugin)
except ImportError:
... |
'Check lazy setup method'
| def testSetup(self):
| r = S3Represent(options=self.test_opts)
self.assertFalse(r.setup)
r._setup()
self.assertTrue(r.setup)
self.assertEqual(r.tablename, None)
self.assertEqual(r.options, self.test_opts)
r = S3Represent(lookup='org_organisation')
self.assertFalse(r.setup)
self.assertEqual(r.options, None)... |
'Test option field representation'
| def testOptions(self):
| r = S3Represent(options=self.test_opts, none='NONE')
self.assertEqual(r(1), 'Test1')
self.assertEqual(r.multiple([1, 2, 3]), 'Test1, Test2, Test3')
self.assertEqual(r.bulk([1, 2, 3]), {1: 'Test1', 2: 'Test2', 3: 'Test3', None: 'NONE'})
r = S3Represent(options=self.test_opts, none='NONE', multi... |
'Test foreign key lookup representation'
| def testForeignKeys(self):
| r = S3Represent(lookup='org_organisation')
self.assertEqual(r(self.id1), self.name1)
self.assertEqual(r(self.id2), self.name2)
self.assertEqual(r.queries, 2)
self.assertEqual(r.multiple([self.id1, self.id2]), ('%s, %s' % (self.name1, self.name2)))
self.assertEqual(r.queries, 2)
result = r... |
'Test Foreign Key Representation in list:reference types'
| def testListReference(self):
| r = S3Represent(lookup='org_organisation', multiple=True, show_link=True)
a = current.request.application
result = r(self.id1)
self.assertTrue(isinstance(result, DIV))
self.assertEqual(len(result), 1)
self.assertTrue(isinstance(result[0], A))
self.assertEqual(result[0].attributes['_href'], (... |
'Test Representation of reference, single value,
without linkto'
| def testRepresentReferenceSingleNoLinkto(self):
| s3db = current.s3db
tablename = self.tablename
fname = ('%s.organisation_id' % tablename)
fac = self.facs[0]
resource = s3db.resource(tablename, id=fac.id)
renderer = S3Represent(lookup='org_organisation')
table = resource.table
table.organisation_id.represent = renderer
data = resou... |
'Test Representation of reference, single value,
with linkto'
| def testRepresentReferenceSingleLinktoOn(self):
| s3db = current.s3db
tablename = self.tablename
fname = ('%s.organisation_id' % tablename)
fac = self.facs[0]
resource = s3db.resource(tablename, id=fac.id)
renderer = S3Represent(lookup='org_organisation', show_link=True)
table = resource.table
table.organisation_id.represent = renderer
... |
'Test Representation of reference, single value,
with linkto + show_link=False'
| def testRepresentReferenceSingleLinktoOff(self):
| s3db = current.s3db
tablename = self.tablename
fname = ('%s.organisation_id' % tablename)
fac = self.facs[0]
resource = s3db.resource(tablename, id=fac.id)
renderer = S3Represent(lookup='org_organisation', linkto=URL(c='org', f='organisation', args=['[id]']))
table = resource.table
table... |
'Test Representation of reference, multiple values,
without linkto'
| def testRepresentReferenceMultipleNoLinkto(self):
| s3db = current.s3db
tablename = self.tablename
fname = ('%s.location_id' % tablename)
ftable = current.db[tablename]
renderer = S3Represent(lookup='gis_location')
ftable.location_id.represent = renderer
resource = s3db.resource('org_organisation', id=self.org.id)
data = resource.select([... |
'Test Representation of reference, multiple values,
with linkto'
| def testRepresentReferenceMultipleLinktoOn(self):
| s3db = current.s3db
tablename = self.tablename
fname = ('%s.location_id' % tablename)
ftable = current.db[tablename]
renderer = S3Represent(lookup='gis_location', show_link=True)
ftable.location_id.represent = renderer
resource = s3db.resource('org_organisation', id=self.org.id)
data = r... |
'Test Representation of reference, multiple values,
with linkto + show_link=False'
| def testRepresentReferenceMultipleLinktoOff(self):
| s3db = current.s3db
tablename = self.tablename
fname = ('%s.location_id' % tablename)
ftable = current.db[tablename]
renderer = S3Represent(lookup='gis_location', linkto=URL(c='gis', f='location', args=['[id]']))
ftable.location_id.represent = renderer
resource = s3db.resource('org_organisat... |
'Test Representation of list:reference, single value,
without linkto'
| def testRepresentListReferenceSingleNoLinkto(self):
| s3db = current.s3db
tablename = self.tablename
fname = ('%s.facility_type_id' % tablename)
fac = self.facs[0]
resource = s3db.resource(tablename, id=fac.id)
renderer = S3Represent(lookup='org_facility_type', multiple=True)
table = resource.table
table.facility_type_id.represent = rendere... |
'Test Representation of list:reference, single value,
with linkto'
| def testRepresentListReferenceSingleLinktoOn(self):
| s3db = current.s3db
tablename = self.tablename
fname = ('%s.facility_type_id' % tablename)
fac = self.facs[0]
resource = s3db.resource(tablename, id=fac.id)
renderer = S3Represent(lookup='org_facility_type', multiple=True, show_link=True)
table = resource.table
table.facility_type_id.rep... |
'Test Representation of list:reference, single value,
with linkto + show_link=False'
| def testRepresentListReferenceSingleLinktoOff(self):
| s3db = current.s3db
tablename = self.tablename
fname = ('%s.facility_type_id' % tablename)
fac = self.facs[0]
resource = s3db.resource(tablename, id=fac.id)
renderer = S3Represent(lookup='org_facility_type', multiple=True, linkto=URL(c='org', f='facility_type', args=['[id]']))
table = resour... |
'Test Representation of list:reference, multiple values,
without linkto'
| def testRepresentListReferenceMultipleNoLinkto(self):
| s3db = current.s3db
tablename = self.tablename
fname = ('%s.location_id' % tablename)
ftable = current.db[tablename]
renderer = S3Represent(lookup='gis_location', linkto=URL(c='gis', f='location', args=['[id]']))
ftable.location_id.represent = renderer
resource = s3db.resource('org_organisat... |
'Test Representation of list:reference, single value,
without linkto'
| def testRepresentListReferenceSingleNoLinkto(self):
| s3db = current.s3db
tablename = self.tablename
fname = ('%s.facility_type_id' % tablename)
ftable = current.db[tablename]
renderer = S3Represent(lookup='org_facility_type', multiple=True)
ftable.facility_type_id.represent = renderer
org = self.org
resource = s3db.resource('org_organisati... |
'Test Representation of list:reference, multiple values,
with linkto'
| def testRepresentListReferenceMultipleLinktoOn(self):
| s3db = current.s3db
s3db = current.s3db
tablename = self.tablename
fname = ('%s.facility_type_id' % tablename)
ftable = current.db[tablename]
renderer = S3Represent(lookup='org_facility_type', multiple=True, show_link=True)
ftable.facility_type_id.represent = renderer
org = self.org
... |
'Test Representation of reference, single value,
without linkto'
| def testRepresentReferenceSingleNoLinkto(self):
| s3db = current.s3db
resource = s3db.resource(self.tablename, id=[fac.id for fac in self.facs])
table = resource.table
org_id_renderer = S3Represent(lookup='org_organisation')
table.organisation_id.represent = org_id_renderer
fac_type_renderer = S3Represent(lookup='org_facility_type', multiple=Tr... |
'Dummy widget'
| def widget1(self):
| pass
|
'Dummy widget'
| def widget2(self):
| pass
|
'Dummy widget'
| def widget3(self):
| pass
|
'Test setting the widget in the instance (no default)'
| def testWidgetOverrideWithoutDefault(self):
| rf = S3ReusableField('test', 'integer')
field = rf()
self.assertEqual(field.widget, None)
field = rf(widget=self.widget1)
self.assertEqual(field.widget, self.widget1)
|
'Test overriding the default widget in the instance'
| def testWidgetOverrideWithDefault(self):
| rf = S3ReusableField('test', 'integer', widget=self.widget1)
field = rf()
self.assertEqual(field.widget, self.widget1)
field = rf(widget=self.widget2)
self.assertEqual(field.widget, self.widget2)
|
'Test using widget set with single widget'
| def testSingleWidget(self):
| rf = S3ReusableField('test', 'integer', widgets=self.widget1)
field = rf()
self.assertEqual(field.widget, self.widget1)
field = rf(widget='default')
self.assertEqual(field.widget, self.widget1)
field = rf(widget=self.widget2)
self.assertEqual(field.widget, self.widget2)
self.assertRaises... |
'Test using widget set with multiple widgets'
| def testMultipleWidgets(self):
| rf = S3ReusableField('test', 'integer', widgets={'default': self.widget1, 'alternative': self.widget2})
field = rf()
self.assertEqual(field.widget, self.widget1)
field = rf(widget='default')
self.assertEqual(field.widget, self.widget1)
field = rf(widget='alternative')
self.assertEqual(field.... |
'Test using widget set with multiple widgets and override default'
| def testMultipleWidgetsWithDefault(self):
| rf = S3ReusableField('test', 'integer', widgets={'default': self.widget1, 'alternative': self.widget2}, widget=self.widget3)
field = rf()
self.assertEqual(field.widget, self.widget3)
field = rf(widget='default')
self.assertEqual(field.widget, self.widget3)
field = rf(widget='alternative')
se... |
'Test fallback to default widget'
| def testFallbackWithDefault(self):
| rf = S3ReusableField('test', 'integer', widget=self.widget1, widgets={'alternative': self.widget2})
field = rf()
self.assertEqual(field.widget, self.widget1)
field = rf(widget='default')
self.assertEqual(field.widget, self.widget1)
field = rf(widget='alternative')
self.assertEqual(field.widg... |
'Test explicit None-widget in instance'
| def testExplicitNone(self):
| rf = S3ReusableField('test', 'integer', widgets={'default': self.widget1, 'alternative': self.widget2}, widget=self.widget3)
field = rf(widget=None)
self.assertEqual(field.widget, None)
|
'Test fallback to None'
| def testFallbackWithoutDefault(self):
| rf = S3ReusableField('test', 'integer', widgets={'alternative': self.widget2})
field = rf()
self.assertEqual(field.widget, None)
field = rf(widget='default')
self.assertEqual(field.widget, None)
field = rf(widget='alternative')
self.assertEqual(field.widget, self.widget2)
field = rf(widg... |
'Test fallback to None'
| def testFallbackWithoutWidgets(self):
| rf = S3ReusableField('test', 'integer')
field = rf()
self.assertEqual(field.widget, None)
field = rf(widget='default')
self.assertEqual(field.widget, None)
self.assertRaises(NameError, rf, widget='alternative')
field = rf(widget=self.widget1)
self.assertEqual(field.widget, self.widget1)
... |
'Test updating a Country with Polygon - including level optimisation'
| def testL0_with_level(self):
| self._testL0(with_level=True)
|
'Test updating a Country with Polygon - without level optimisation'
| def testL0_without_level(self):
| self._testL0(with_level=False)
|
'Test updating a normal L1, with L0 Parent - including level optimisation'
| def testL1_with_level(self):
| self._testL1(with_level=True)
|
'Test updating a normal L1, with L0 Parent - without level optimisation'
| def testL1_without_level(self):
| self._testL1(with_level=False)
|
'Test updating a normal L2, with normal L1 Parent - including level optimisation'
| def testL2_with_level(self):
| self._testL2(with_level=True)
|
'Test updating a normal L2, with normal L1 Parent - without level optimisation'
| def testL2_without_level(self):
| self._testL2(with_level=False)
|
'Test updating a normal L3, with normal L2 Parent - including level optimisation'
| def testL3_with_level(self):
| self._testL3(with_level=True)
|
'Test updating a normal L3, with normal L2 Parent - without level optimisation'
| def testL3_without_level(self):
| self._testL3(with_level=False)
|
'Test updating a normal L4, with normal L3 Parent - including level optimisation'
| def testL4_with_level(self):
| self._testL4(with_level=True)
|
'Test updating a normal L4, with normal L3 Parent - without level optimisation'
| def testL4_without_level(self):
| self._testL4(with_level=False)
|
'Test updating a normal L5, with normal L4 Parent - including level optimisation'
| def testL5_with_level(self):
| self._testL5(with_level=True)
|
'Test updating a normal L5, with normal L4 Parent - without level optimisation'
| def testL5_without_level(self):
| self._testL5(with_level=False)
|
'Test updating an L3, without an L2 Parent, going straight to L1 - including level optimisation'
| def testL3_L1_parent_with_level(self):
| self._testL3_L1_parent(with_level=True)
|
'Test updating an L3, without an L2 Parent, going straight to L1 - without level optimisation'
| def testL3_L1_parent_without_level(self):
| self._testL3_L1_parent(with_level=False)
|
'Test inserting a location during prepop with location tree updates disabled'
| def testULT1_update_location_tree_disabled(self):
| from s3.s3gis import GIS
table = self.table
db = current.db
gis = current.gis
L0_lat = 10.0
L0_lon = (-10.0)
L0_id = table.insert(level='L0', name='s3gis.testULT1.L0', lat=L0_lat, lon=L0_lon)
L1_id = table.insert(level='L1', name='s3gis.testULT1.L1', parent=L0_id)
GIS.disable_update_... |
'Test that the all locations update updates locations'
| def testULT2_update_location_tree_all_locations(self):
| from s3.s3gis import GIS
table = self.table
db = current.db
gis = current.gis
GIS.disable_update_location_tree = True
L0_lat = 10.0
L0_lon = (-10.0)
L0_id = table.insert(level='L0', name='s3gis.testULT2.L0', lat=L0_lat, lon=L0_lon)
L1_id = table.insert(level='L1', name='s3gis.testULT... |
'Test that the all locations update does not get a "too much recursion" error.'
| def testULT3_update_location_tree_all_locations_no_infinite_recursion(self):
| table = self.table
L0_id = table.insert(level='L0', name='s3gis.testULT3.L0', lat=10.0, lon=(-10.0))
L1_id = table.insert(level='L1', name='s3gis.testULT3.L1', parent=L0_id)
L3_id = table.insert(level='L3', name='s3gis.testULT3.L3', parent=L1_id)
specific_id = table.insert(name='s3gis.testULT3.speci... |
'Test get_parents in a case that causes it to call update_location_tree.'
| def testULT4_get_parents(self):
| table = self.table
gis = current.gis
L0_id = table.insert(level='L0', name='s3gis.testULT4.L0', lat=10.0, lon=(-10.0))
L1_id = table.insert(level='L1', name='s3gis.testULT4.L1', parent=L0_id)
L3_id = table.insert(level='L3', name='s3gis.testULT4.L3', parent=L1_id)
specific_id = table.insert(name... |
'Test updating a Country with Polygon'
| def _testL0(self, with_level):
| LEVEL = 'L0'
POLYGON = 'POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))'
L0 = ('%s_%s' % (self.L0, with_level))
table = self.table
form = Storage(vars=Storage(level=LEVEL, name=L0, wkt=POLYGON), errors=None)
current.gis.wkt_centroid(form)
L0_id = table.insert(**fo... |
'Test updating a normal L1, with L0 Parent'
| def _testL1(self, with_level):
| LEVEL = 'L1'
POLYGON = 'POLYGON ((30 11, 39 39, 21 39, 11 20, 30 11))'
L0 = ('%s_%s' % (self.L0, with_level))
L1 = ('%s_%s' % (self.L1, with_level))
L0_id = self.ids[L0]
table = self.table
form = Storage(vars=Storage(level=LEVEL, name=L1, parent=L0_id, wkt=POLYG... |
'Test updating a normal L2, with normal L1 Parent'
| def _testL2(self, with_level):
| LEVEL = 'L2'
POLYGON = 'POLYGON ((30 12, 38 38, 22 38, 12 20, 30 12))'
L0 = ('%s_%s' % (self.L0, with_level))
L1 = ('%s_%s' % (self.L1, with_level))
L2 = ('%s_%s' % (self.L2, with_level))
L0_id = self.ids[L0]
L1_id = self.ids[L1]
table = self.table
form ... |
'Test updating a normal L3, with normal L2 Parent'
| def _testL3(self, with_level):
| LEVEL = 'L3'
POLYGON = 'POLYGON ((30 13, 37 37, 23 37, 13 20, 30 13))'
L0 = ('%s_%s' % (self.L0, with_level))
L1 = ('%s_%s' % (self.L1, with_level))
L2 = ('%s_%s' % (self.L2, with_level))
L3 = ('%s_%s' % (self.L3, with_level))
L0_id = self.ids[L0]
L1_id = se... |
'Test updating a normal L4, with normal L3 Parent'
| def _testL4(self, with_level):
| LEVEL = 'L4'
POLYGON = 'POLYGON ((30 14, 36 36, 24 36, 14 20, 30 14))'
L0 = ('%s_%s' % (self.L0, with_level))
L1 = ('%s_%s' % (self.L1, with_level))
L2 = ('%s_%s' % (self.L2, with_level))
L3 = ('%s_%s' % (self.L3, with_level))
L4 = ('%s_%s' % (self.L4, with_leve... |
'Test updating a normal L5, with normal L4 Parent'
| def _testL5(self, with_level):
| LEVEL = 'L5'
POLYGON = 'POLYGON ((30 15, 35 35, 23 35, 15 20, 30 15))'
L0 = ('%s_%s' % (self.L0, with_level))
L1 = ('%s_%s' % (self.L1, with_level))
L2 = ('%s_%s' % (self.L2, with_level))
L3 = ('%s_%s' % (self.L3, with_level))
L4 = ('%s_%s' % (self.L4, with_leve... |
'Test updating an L3, without an L2 Parent, going straight to L1
- this is like Cotabato City & Isabela City in the Philippines'
| def _testL3_L1_parent(self, with_level):
| LEVEL = 'L3'
POLYGON = 'POLYGON ((30 13, 37 37, 23 37, 13 20, 30 13))'
L0 = ('%s_%s' % (self.L0, with_level))
L1 = ('%s_%s' % (self.L1, with_level))
L3 = 'Test of Cotabato City'
L0_id = self.ids[L0]
L1_id = self.ids[L1]
table = self.table
form =... |
'Test series-method'
| def testSeries(self):
| series = S3TimeSeriesEvent.series
assertEqual = self.assertEqual
assertEqual(series(None), set([None]))
assertEqual(series(0), set([0]))
assertEqual(series('A'), set(['A']))
assertEqual(series([]), set())
assertEqual(series([[], []]), set())
assertEqual(series(['A', 'B']), set(['A', 'B']... |
'Test event construction'
| def testConstruction(self):
| assertEqual = self.assertEqual
assertTrue = self.assertTrue
start = tp_datetime(2004, 1, 1)
end = tp_datetime(2004, 3, 21)
event_id = 1
values = {'test': 2}
event = S3TimeSeriesEvent(event_id, start=start, end=end)
assertEqual(event.event_id, event_id)
assertTrue(isinstance(event.val... |
'Test comparison method __lt__ for events (by sorting them)'
| def testComparison(self):
| data = [(8, (2012, 1, 12), (2013, 9, 19)), (2, None, (2013, 4, 21)), (6, (2013, 4, 14), (2013, 5, 7)), (3, (2012, 4, 21), (2013, 6, 3)), (4, (2013, 4, 18), (2013, 5, 27))]
events = []
for (event_id, start, end) in data:
event_start = (tp_datetime(*start) if start else None)
event_end = (tp_d... |
'Verify events in test period'
| def testEvents(self):
| assertTrue = self.assertTrue
cevents = self.period.cevents
for item in self.current_events:
assertTrue((item[0] in cevents))
pevents = self.period.pevents
for item in self.previous_events:
assertTrue((item[0] in pevents))
|
'Test computation of event duration before the end of a period'
| def testDuration(self):
| events = (((2013, 1, 1, 0, 0, 0), (2013, 1, 31, 0, 0, 0), 31), ((2013, 3, 1, 0, 0, 0), (2013, 4, 2, 0, 0, 0), 33), ((2013, 3, 8, 0, 0, 0), (2013, 8, 5, 0, 0, 0), 116), ((2013, 5, 1, 0, 0, 0), (2013, 9, 21, 0, 0, 0), 62), ((2013, 5, 1, 0, 0, 0), (2013, 5, 5, 0, 0, 0), 5), ((2013, 8, 5, 0, 0, 0), (2013, 9, 16, 0, 0, ... |
'Test grouping of period events'
| def testGrouping(self):
| period = self.period
period.group()
assertTrue = self.assertTrue
assertEqual = self.assertEqual
expected_rows = {'A': ((1, 2, 7, 8), ()), 'B': ((3, 4, 9, 10), ()), 'C': ((5, 6, 11, 12), ())}
rows = period._rows
assertEqual(set(rows.keys()), set(expected_rows.keys()))
for (k, v) in rows.i... |
'Test grouping of period events including previous events'
| def testGroupingCumulative(self):
| period = self.period
period.group(cumulative=True)
assertTrue = self.assertTrue
assertEqual = self.assertEqual
expected_rows = {'A': ((1, 2, 7, 8), (13,)), 'B': ((3, 4, 9, 10), (14,)), 'C': ((5, 6, 11, 12), (15, 16))}
rows = period._rows
assertEqual(set(rows.keys()), set(expected_rows.keys()... |
'Test aggregation: count'
| def testAggregateCount(self):
| period = self.period
assertEqual = self.assertEqual
totals = period.aggregate(S3TimeSeriesFact('count', 'base'))
expected_rows = {'A': [4], 'B': [4], 'C': [4]}
rows = period.rows
assertEqual(set(rows.keys()), set(expected_rows.keys()))
for (k, v) in rows.items():
assertEqual(v, expec... |
'Test aggregation: sum'
| def testAggregateSum(self):
| period = self.period
assertEqual = self.assertEqual
totals = period.aggregate(S3TimeSeriesFact('sum', 'base'))
expected_rows = {'A': [180], 'B': [370], 'C': [810]}
rows = period.rows
assertEqual(set(rows.keys()), set(expected_rows.keys()))
for (k, v) in rows.items():
assertEqual(v, e... |
'Test aggregation: avg'
| def testAggregateAvg(self):
| period = self.period
assertEqual = self.assertEqual
assertAlmostEqual = self.assertAlmostEqual
totals = period.aggregate(S3TimeSeriesFact('avg', 'base'))
expected_rows = {'A': [45], 'B': [92.5], 'C': [202.5]}
rows = period.rows
assertEqual(set(rows.keys()), set(expected_rows.keys()))
for... |
'Test aggregation: min/max (combined)'
| def testAggregateMinMax(self):
| period = self.period
assertEqual = self.assertEqual
totals = period.aggregate([S3TimeSeriesFact('min', 'base'), S3TimeSeriesFact('max', 'base')])
expected_rows = {'A': [10, 80], 'B': [30, 200], 'C': [50, 400]}
rows = period.rows
assertEqual(set(rows.keys()), set(expected_rows.keys()))
for (k... |
'Test aggregation: sum/cumulate (combined)'
| def testAggregateCumulate(self):
| period = self.period
assertEqual = self.assertEqual
totals = period.aggregate([S3TimeSeriesFact('sum', 'base'), S3TimeSeriesFact('cumulate', 'base', slope='slope', interval='days')])
expected_rows = {'A': [180, 369], 'B': [370, 709], 'C': [810, 1170]}
rows = period.rows
assertEqual(set(rows.keys... |
'Test grouping of period events (single axis)'
| def testGrouping(self):
| period = self.period
period.group()
assertTrue = self.assertTrue
assertEqual = self.assertEqual
expected_rows = {'A': ((1, 2, 7, 8), ()), 'B': ((3, 4, 9, 10), ()), 'C': ((5, 6, 11, 12), ())}
rows = period._rows
assertEqual(set(rows.keys()), set(expected_rows.keys()))
for (k, v) in rows.i... |
'Test grouping of period events including previous events (single axis)'
| def testGroupingCumulative(self):
| period = self.period
period.group(cumulative=True)
assertTrue = self.assertTrue
assertEqual = self.assertEqual
expected_rows = {'A': ((1, 2, 7, 8), (13,)), 'B': ((3, 4, 9, 10), (14,)), 'C': ((5, 6, 11, 12), (15, 16))}
rows = period._rows
assertEqual(set(rows.keys()), set(expected_rows.keys()... |
'Test aggregation: count (single axis)'
| def testAggregateCount(self):
| period = self.period
assertEqual = self.assertEqual
totals = period.aggregate(S3TimeSeriesFact('count', 'base'))
expected_rows = {'A': [4], 'B': [4], 'C': [4]}
rows = period.rows
assertEqual(set(rows.keys()), set(expected_rows.keys()))
for (k, v) in rows.items():
assertEqual(v, expec... |
'Test aggregation: sum (single axis)'
| def testAggregateSum(self):
| period = self.period
assertEqual = self.assertEqual
totals = period.aggregate(S3TimeSeriesFact('sum', 'base'))
expected_rows = {'A': [180], 'B': [370], 'C': [810]}
rows = period.rows
assertEqual(set(rows.keys()), set(expected_rows.keys()))
for (k, v) in rows.items():
assertEqual(v, e... |
'Test grouping of period events (no grouping)'
| def testGrouping(self):
| period = self.period
period.group()
assertTrue = self.assertTrue
assertEqual = self.assertEqual
assertEqual(period._rows, {})
assertEqual(period._cols, {})
assertEqual(period._matrix, {})
|
'Test grouping of period events including previous events (no grouping)'
| def testGroupingCumulative(self):
| period = self.period
period.group(cumulative=True)
assertTrue = self.assertTrue
assertEqual = self.assertEqual
assertEqual(period._rows, {})
assertEqual(period._cols, {})
assertEqual(period._matrix, {})
|
'Test aggregation: count (no grouping)'
| def testAggregateCount(self):
| period = self.period
assertEqual = self.assertEqual
totals = period.aggregate(S3TimeSeriesFact('count', 'base'))
assertEqual(period.rows, {})
assertEqual(period.cols, {})
assertEqual(period.matrix, {})
expected_totals = [12]
assertEqual(period.totals, expected_totals)
assertEqual(tot... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.