def setUp(self): params = { 'title': 'My nodetype', 'content': 'My content', 'tags': 'gstudio, test', 'slug': 'my-nodetype' } self.nodetype = Nodetype.objects.create(**params) self.pinger = DirectoryPinger('http://localhost', [self.nodetype], start_now=False)
def setUp(self): params = {'title': 'My nodetype', 'content': 'My content', 'tags': 'gstudio, test', 'slug': 'my-nodetype'} self.nodetype = Nodetype.objects.create(**params) self.pinger = DirectoryPinger('http://localhost', [self.nodetype], start_now=False)
def ping_directories_handler(sender, **kwargs): """Ping Directories when a nodetype is saved""" nodetype = kwargs['instance'] if nodetype.is_visible and settings.SAVE_PING_DIRECTORIES: from gstudio.ping import DirectoryPinger for directory in settings.PING_DIRECTORIES: DirectoryPinger(directory, [nodetype])
def ping_directories(self, request, queryset, messages=True): """Ping Directories for selected relationtypes""" for directory in settings.PING_DIRECTORIES: pinger = DirectoryPinger(directory, queryset) pinger.join() if messages: success = 0 for result in pinger.results: if not result.get('flerror', True): success += 1 else: self.message_user(request, '%s : %s' % (directory, result['message'])) if success: self.message_user( request, _('%(directory)s directory succesfully ' \ 'pinged %(success)d relationtypes.') % {'directory': directory, 'success': success})
def ping_directories(self, request, queryset, messages=True): """Ping Directories for selected processtypes""" for directory in settings.PING_DIRECTORIES: pinger = DirectoryPinger(directory, queryset) pinger.join() if messages: success = 0 for result in pinger.results: if not result.get('flerror', True): success += 1 else: self.message_user( request, '%s : %s' % (directory, result['message'])) if success: self.message_user( request, _('%(directory)s directory succesfully ' \ 'pinged %(success)d processtypes.') % {'directory': directory, 'success': success})
class DirectoryPingerTestCase(TestCase): """Test cases for DirectoryPinger""" def setUp(self): params = {'title': 'My nodetype', 'content': 'My content', 'tags': 'gstudio, test', 'slug': 'my-nodetype'} self.nodetype = Nodetype.objects.create(**params) self.pinger = DirectoryPinger('http://localhost', [self.nodetype], start_now=False) def test_ping_nodetype(self): self.assertEquals( self.pinger.ping_nodetype(self.nodetype), {'message': 'http://localhost is an invalid directory.', 'flerror': True})
class DirectoryPingerTestCase(TestCase): """Test cases for DirectoryPinger""" def setUp(self): params = { 'title': 'My nodetype', 'content': 'My content', 'tags': 'gstudio, test', 'slug': 'my-nodetype' } self.nodetype = Nodetype.objects.create(**params) self.pinger = DirectoryPinger('http://localhost', [self.nodetype], start_now=False) def test_ping_nodetype(self): self.assertEquals( self.pinger.ping_nodetype(self.nodetype), { 'message': 'http://localhost is an invalid directory.', 'flerror': True })