# -*- encoding: UTF8 -*- # Test harness for DefaultSwarmReviewDesc.py from __future__ import print_function import sys import unittest import os from p4testutils import TestCase, P4Server parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.insert(0, parent_dir) from DefaultSwarmReviewDesc import DefaultSwarmReviewDesc os.environ["LOGS"] = "." LOGGER_NAME = "DefaultSwarmReviewDesc" LOG_FILE = "log-DefaultSwarmReviewDesc.log" class TestDefaultSwarmReviewDesc(TestCase): def __init__(self, methodName='runTest'): super(TestDefaultSwarmReviewDesc, self).__init__(LOGGER_NAME, LOG_FILE, methodName=methodName) def setUp(self): pass def tearDown(self): pass def setupServer(self, config_path): self.server = P4Server() trig_path = os.path.join(parent_dir, "DefaultSwarmReviewDesc.py") p4 = self.server.p4 p4.logger = self.logger # This works if no spaces in server root pathname! port = p4.port.replace('"', '') self.logger.debug("port: |%s|" % port) triggers = p4.fetch_triggers() triggers['Triggers'] = ['default-swarm-desc form-in change "python {} -c {}' ' -p %quote%{}%quote% -u {} %user% %formfile%"'.format( trig_path, config_path, port, p4.user)] self.logger.debug(triggers) p4.save_triggers(triggers) # Reconnect to pick up changes p4.disconnect() p4.connect() return p4 def testChangeDesc(self): """jobs are renamed for p4dtg""" config_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "~test_config.yaml") p4 = self.setupServer(config_path) with open(config_path, "w") as f: f.write(""" swarm_user: swarm review_description: - "Please review me!" - "Don't forget to check YYYY" """) chg = p4.fetch_change() chg["Description"] = "My change description" p4.save_change(chg) # Make sure that the trigger doesn't fire again - so what is put in above survives chg = p4.fetch_change("1") self.assertRegex(chg["Description"], "My change description") # Now process as user defined in config file p4.user = "swarm" chg = p4.fetch_change() chg["Description"] = "Change desc 2" p4.save_change(chg) # Test that the template is updated from config file chg = p4.fetch_change("2") self.assertRegex(chg["Description"], "Please review me!") chg["Description"] = "New change desc" p4.save_change(chg) # Make sure that the trigger doesn't fire again - so what is put in above survives chg = p4.fetch_change("2") self.assertRegex(chg["Description"], "New change desc") if __name__ == '__main__': unittest.main()
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 26652 | Robert Cowham |
This is Tom's change: Introduced new 'Unsupported' directory to clarify that some files in the SDP are not officially supported. These files are samples for illustration, to provide examples, or are deprecated but not yet ready for removal from the package. The Maintenance and many SDP triggers have been moved under here, along with other SDP scripts and triggers. Added comments to p4_vars indicating that it should not be edited directly. Added reference to an optional site_global_vars file that, if it exists, will be sourced to provide global user settings without needing to edit p4_vars. As an exception to the refactoring, the totalusers.py Maintenance script will be moved to indicate that it is supported. Removed settings to support long-sunset P4Web from supported structure. Structure under new .../Unsupported folder is: Samples/bin Sample scripts. Samples/triggers Sample trigger scripts. Samples/triggers/tests Sample trigger script tests. Samples/broker Sample broker filter scripts. Deprecated/triggers Deprecated triggers. To Do in a subsequent change: Make corresponding doc changes. |
||
#1 | 23289 | Robert Cowham | Trigger to create a default swarm review description |