def setUp(self): """ Method used to setup the test database """ # create a new user user = User.objects.create_user('root', '*****@*****.**', 'root') user.is_superuser = True user.save() token = Token.objects.create(user=user) # create a new Plugin plugin = Plugin() plugin.title = 'My test plugin' plugin.description = '' plugin.active_version = '1.0.0' plugin.plugin_version = '1.0.0' plugin.url_info = 'http://active.crs4.it' plugin.authors = 'John Doe' plugin.save() # create a new Script script = Script() script.title = 'Test script for image items' script.details = '' script.path = 'mytestplugin.utils.script1' script.job_name = 'job_manager.job.job.PlainJob' script.plugin = plugin script.item_type = 'image' script.save()
def extract_scripts(self, section): """ The method is used to extract all informations related to a script (except for the event data that must be associated later). @param section: The section containg current script related data. @returns: A Script object constructed extracting section data. """ # detect if the plugin has already been stored s= None try: s = Script.objects.get(path = section['path']) # otherwise create a new one except Script.DoesNotExist as ex: s = Script(**section) s.save() return s
def create_script(event_id=1, plugin_id=1): """ Method used to create and return a simple Script object. """ event = Event.objects.get(pk=event_id) plugin = Plugin.objects.get(pk=plugin_id) script = Script() script.title = "org.module.test" script.plugin = plugin script.save() script.events.add(event) script.save() return script