def test_bicikelj(self): node = next(itertools.islice(nodes.get_all_nodes(), 12, 13)) self.assertEqual(node.name, 'fri') request = self.factory.get('/') request.session = { nodes.SESSION_KEY: node.id, nodes.BACKEND_SESSION_KEY: node.backend.get_full_name(), } request.node = nodes.get_node(request) self.assertEqual(node.id, request.node.id) context = template.RequestContext(request) data = {} on_template_render = functional.curry(client.store_rendered_templates, data) signals.template_rendered.connect(on_template_render, dispatch_uid="template-render") try: panel.BicikeljPanel().render(request, context) finally: signals.template_rendered.disconnect(dispatch_uid="template-render") self.assertEqual(len(data['context']['stations']), 1)
def test_bicikelj(self): node = next(itertools.islice(nodes.get_all_nodes(), 12, 13)) self.assertEqual(node.name, 'fri') request = self.factory.get('/') request.session = { nodes.SESSION_KEY: node.id, nodes.BACKEND_SESSION_KEY: node.backend.get_full_name(), } request.node = nodes.get_node(request) self.assertEqual(node.id, request.node.id) context = template.RequestContext(request) data = {} def store_rendered_templates(signal, sender, template, context, **kwargs): for d in context.dicts: for e in d.dicts: data.update(e) signals.template_rendered.connect(store_rendered_templates, dispatch_uid="template-render") try: panel.BicikeljPanel().render(request, context) finally: signals.template_rendered.disconnect(dispatch_uid="template-render") self.assertEqual(len(data['stations']), 1)
def generate_weather_tasks(): """ Task which updates weather for all nodes. Obsolete data is currently left in the database. """ weather_tasks = [] # Fetching data only once per possible duplicate locations for latitude, longitude in {(node.latitude, node.longitude) for node in nodes.get_all_nodes()}: weather_tasks.append(update_weather.s(latitude, longitude)) return celery.group(weather_tasks)()
def location_choices(): yield (NO_MOCKING_ID, _("Don't mock location")) for node in nodes.get_all_nodes(): yield (node.get_full_node_id(), node.name)