# -*- encoding: UTF8 -*- # Test harness for DefaultChangeDesc.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 DefaultChangeDesc import DefaultChangeDesc os.environ["LOGS"] = "." LOGGER_NAME = "DefaultChangeDesc" LOG_FILE = "log-DefaultChangeDesc.log" class TestDefaultChangeDesc(TestCase): def __init__(self, methodName='runTest'): super(TestDefaultChangeDesc, self).__init__(LOGGER_NAME, LOG_FILE, methodName=methodName) def setUp(self): pass def tearDown(self): pass def setupServer(self): self.server = P4Server() trig_path = os.path.join(parent_dir, "DefaultChangeDesc.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-change-desc form-out change "python {} -p %quote%{}%quote% ' '-u {} %user% %formfile%"'.format(trig_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""" p4 = self.setupServer() chg = p4.fetch_change() self.assertRegex(chg["Description"], "OS-NNNN.*") 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") if __name__ == '__main__': unittest.main()
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 27331 | C. Thomas Tyler |
Released SDP 2020.1.27325 (2021/01/29). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
//guest/perforce_software/sdp/dev/Unsupported/Samples/triggers/tests/TestDefaultChangeDesc.py | |||||
#1 | 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. |
||
//guest/perforce_software/sdp/dev/Server/Unix/p4/common/bin/triggers/tests/TestDefaultChangeDesc.py | |||||
#4 | 23575 | Robert Cowham | Refactor how trigger table is constructed | ||
#3 | 23288 | Robert Cowham | Test for already created changes | ||
#2 | 23242 | Robert Cowham |
Handle restricted changes (describe requires -f) Don't overwrite a changed changelist description |
||
#1 | 23241 | Robert Cowham | New triggers with tests |