Bladeren bron

Ticket 48832 - Fix pytest compatibility in CI tests

Description: For pytest compatibility all test suites should have test
functions starting with 'test' word. Fix it. Also clean up the tests
from old 'run_isolated' functions.

https://fedorahosted.org/389/ticket/48832

Reviewed by: mreynolds (Thanks!)
Simon Pichugin 9 jaren geleden
bovenliggende
commit
d193997f70

+ 6 - 26
dirsrvtests/tests/tickets/ticket142_test.py

@@ -104,7 +104,7 @@ def check_attr_val(topology, dn, attr, expected):
         assert False
 
 
-def _142_init(topology):
+def test_142_init(topology):
     """
     Set global password policy.
     Then, set fine-grained subtree level password policy to ou=People with no password syntax.
@@ -155,7 +155,7 @@ def _142_init(topology):
                                    '(targetattr="*")(version 3.0; acl "pwp test"; allow (all) userdn="ldap:///%s";)' % BN)])
 
 
-def _142_run_0(topology):
+def test_142_run_0(topology):
     """
     Make sure an entry added to ou=people has no password syntax restrictions.
     """
@@ -175,7 +175,7 @@ def _142_run_0(topology):
     log.info('PASSED')
 
 
-def _142_run_1(topology):
+def test_142_run_1(topology):
     """
     Set 'nsslapd-pwpolicy-inherit-global: on'
     But passwordCheckSyntax is still off.
@@ -201,7 +201,7 @@ def _142_run_1(topology):
     log.info('PASSED')
 
 
-def _142_run_2(topology):
+def test_142_run_2(topology):
     """
     Set 'passwordCheckSyntax: on'
     Set 'passwordMinLength: 9' for testing
@@ -244,7 +244,7 @@ def _142_run_2(topology):
     log.info('PASSED')
 
 
-def _142_run_3(topology):
+def test_142_run_3(topology):
     """
     Set 'passwordCheckSyntax: on'
     Set 'nsslapd-pwpolicy-inherit-global: off'
@@ -271,7 +271,7 @@ def _142_run_3(topology):
     log.info('PASSED')
 
 
-def _142_run_4(topology):
+def test_142_run_4(topology):
     """
     Set 'passwordCheckSyntax: on'
     Set 'nsslapd-pwpolicy-inherit-global: on'
@@ -300,26 +300,6 @@ def _142_run_4(topology):
     log.info('PASSED')
 
 
-def test_ticket142(topology):
-    '''
-        run_isolated is used to run these test cases independently of a test scheduler (xunit, py.test..)
-        To run isolated without py.test, you need to
-            - edit this file and comment '@pytest.fixture' line before 'topology' function.
-            - set the installation prefix
-            - run this program
-    '''
-    global installation_prefix
-    installation_prefix = None
-
-    _142_init(topology)
-
-    _142_run_0(topology)
-    _142_run_1(topology)
-    _142_run_2(topology)
-    _142_run_3(topology)
-    _142_run_4(topology)
-
-
 if __name__ == '__main__':
     # Run isolated
     # -s for DEBUG mode

+ 18 - 18
dirsrvtests/tests/tickets/ticket47838_test.py

@@ -96,7 +96,7 @@ def _header(topology, label):
     topology.standalone.log.info("###############################################")
 
 
-def _47838_init(topology):
+def test_47838_init(topology):
     """
     Generate self signed cert and import it to the DS cert db.
     Enable SSL
@@ -200,7 +200,7 @@ def comp_nsSSLEnableCipherCount(topology, ecount):
     assert ecount == enabledciphercnt
 
 
-def _47838_run_0(topology):
+def test_47838_run_0(topology):
     """
     Check nsSSL3Ciphers: +all
     All ciphers are enabled except null.
@@ -240,7 +240,7 @@ def _47838_run_0(topology):
     comp_nsSSLEnableCipherCount(topology, ecount)
 
 
-def _47838_run_1(topology):
+def test_47838_run_1(topology):
     """
     Check nsSSL3Ciphers: +all
     All ciphers are enabled except null.
@@ -283,7 +283,7 @@ def _47838_run_1(topology):
     comp_nsSSLEnableCipherCount(topology, ecount)
 
 
-def _47838_run_2(topology):
+def test_47838_run_2(topology):
     """
     Check nsSSL3Ciphers: +rsa_aes_128_sha,+rsa_aes_256_sha
     rsa_aes_128_sha, tls_rsa_aes_128_sha, rsa_aes_256_sha, tls_rsa_aes_256_sha are enabled.
@@ -315,7 +315,7 @@ def _47838_run_2(topology):
     comp_nsSSLEnableCipherCount(topology, ecount)
 
 
-def _47838_run_3(topology):
+def test_47838_run_3(topology):
     """
     Check nsSSL3Ciphers: -all
     All ciphers are disabled.
@@ -346,7 +346,7 @@ def _47838_run_3(topology):
     comp_nsSSLEnableCipherCount(topology, ecount)
 
 
-def _47838_run_4(topology):
+def test_47838_run_4(topology):
     """
     Check no nsSSL3Ciphers
     Default ciphers are enabled.
@@ -385,7 +385,7 @@ def _47838_run_4(topology):
     comp_nsSSLEnableCipherCount(topology, ecount)
 
 
-def _47838_run_5(topology):
+def test_47838_run_5(topology):
     """
     Check nsSSL3Ciphers: default
     Default ciphers are enabled.
@@ -424,7 +424,7 @@ def _47838_run_5(topology):
     comp_nsSSLEnableCipherCount(topology, ecount)
 
 
-def _47838_run_6(topology):
+def test_47838_run_6(topology):
     """
     Check nsSSL3Ciphers: +all,-rsa_rc4_128_md5
     All ciphers are disabled.
@@ -458,7 +458,7 @@ def _47838_run_6(topology):
     comp_nsSSLEnableCipherCount(topology, ecount)
 
 
-def _47838_run_7(topology):
+def test_47838_run_7(topology):
     """
     Check nsSSL3Ciphers: -all,+rsa_rc4_128_md5
     All ciphers are disabled.
@@ -490,7 +490,7 @@ def _47838_run_7(topology):
     comp_nsSSLEnableCipherCount(topology, ecount)
 
 
-def _47838_run_8(topology):
+def test_47838_run_8(topology):
     """
     Check nsSSL3Ciphers: default + allowWeakCipher: off
     Strong Default ciphers are enabled.
@@ -529,7 +529,7 @@ def _47838_run_8(topology):
     comp_nsSSLEnableCipherCount(topology, ecount)
 
 
-def _47838_run_9(topology):
+def test_47838_run_9(topology):
     """
     Check no nsSSL3Ciphers
     Default ciphers are enabled.
@@ -572,7 +572,7 @@ def _47838_run_9(topology):
     comp_nsSSLEnableCipherCount(topology, ecount)
 
 
-def _47838_run_10(topology):
+def test_47838_run_10(topology):
     """
     Check nsSSL3Ciphers: -TLS_RSA_WITH_NULL_MD5,+TLS_RSA_WITH_RC4_128_MD5,
         +TLS_RSA_EXPORT_WITH_RC4_40_MD5,+TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5,
@@ -620,7 +620,7 @@ def _47838_run_10(topology):
     comp_nsSSLEnableCipherCount(topology, ecount)
 
 
-def _47838_run_11(topology):
+def test_47838_run_11(topology):
     """
     Check nsSSL3Ciphers: +fortezza
     SSL_GetImplementedCiphers does not return this as a secuire cipher suite
@@ -647,7 +647,7 @@ def _47838_run_11(topology):
     comp_nsSSLEnableCipherCount(topology, 0)
 
 
-def _47928_run_0(topology):
+def test_47928_run_0(topology):
     """
     No SSL version config parameters.
     Check SSL3 (TLS1.0) is off.
@@ -682,7 +682,7 @@ def _47928_run_0(topology):
         assert False
 
 
-def _47928_run_1(topology):
+def test_47928_run_1(topology):
     """
     No nsSSL3, nsTLS1; sslVersionMin > sslVersionMax
     Check sslVersionMax is ignored.
@@ -716,7 +716,7 @@ def _47928_run_1(topology):
         assert False
 
 
-def _47928_run_2(topology):
+def test_47928_run_2(topology):
     """
     nsSSL3: on; sslVersionMin: TLS1.1; sslVersionMax: TLS1.2
     Conflict between nsSSL3 and range; nsSSL3 is disabled
@@ -759,7 +759,7 @@ def _47928_run_2(topology):
         assert False
 
 
-def _47928_run_3(topology):
+def test_47928_run_3(topology):
     """
     nsSSL3: on; nsTLS1: off; sslVersionMin: TLS1.1; sslVersionMax: TLS1.2
     Conflict between nsSSL3/nsTLS1 and range; nsSSL3 is disabled; nsTLS1 is enabled.
@@ -803,7 +803,7 @@ def _47928_run_3(topology):
         assert False
 
 
-def _47838_run_last(topology):
+def test_47838_run_last(topology):
     """
     Check nsSSL3Ciphers: all <== invalid value
     All ciphers are disabled.

+ 13 - 35
dirsrvtests/tests/tickets/ticket48194_test.py

@@ -82,7 +82,7 @@ def _header(topology, label):
     topology.standalone.log.info("###############################################")
 
 
-def my_test_init(topology):
+def test_init(topology):
     """
     Generate self signed cert and import it to the DS cert db.
     Enable SSL
@@ -204,7 +204,7 @@ def connectWithOpenssl(topology, cipher, expect):
                     proc.stdin.close()
                     assert False
 
-def my_test_run_0(topology):
+def test_run_0(topology):
     """
     Check nsSSL3Ciphers: +all
     All ciphers are enabled except null.
@@ -221,7 +221,7 @@ def my_test_run_0(topology):
     connectWithOpenssl(topology, 'RC4-SHA', True)
     connectWithOpenssl(topology, 'AES256-SHA256', True)
 
-def my_test_run_1(topology):
+def test_run_1(topology):
     """
     Check nsSSL3Ciphers: +all
     All ciphers are enabled except null.
@@ -243,7 +243,7 @@ def my_test_run_1(topology):
     connectWithOpenssl(topology, 'RC4-SHA', False)
     connectWithOpenssl(topology, 'AES256-SHA256', True)
 
-def my_test_run_2(topology):
+def test_run_2(topology):
     """
     Check nsSSL3Ciphers: +rsa_aes_128_sha,+rsa_aes_256_sha
     rsa_aes_128_sha, tls_rsa_aes_128_sha, rsa_aes_256_sha, tls_rsa_aes_256_sha are enabled.
@@ -265,7 +265,7 @@ def my_test_run_2(topology):
     connectWithOpenssl(topology, 'AES128-SHA', True)
     connectWithOpenssl(topology, 'AES256-SHA', True)
 
-def my_test_run_3(topology):
+def test_run_3(topology):
     """
     Check nsSSL3Ciphers: -all
     All ciphers are disabled.
@@ -285,7 +285,7 @@ def my_test_run_3(topology):
     connectWithOpenssl(topology, 'RC4-SHA', False)
     connectWithOpenssl(topology, 'AES256-SHA256', False)
 
-def my_test_run_4(topology):
+def test_run_4(topology):
     """
     Check no nsSSL3Ciphers
     Default ciphers are enabled.
@@ -305,7 +305,7 @@ def my_test_run_4(topology):
     connectWithOpenssl(topology, 'RC4-SHA', False)
     connectWithOpenssl(topology, 'AES256-SHA256', True)
 
-def my_test_run_5(topology):
+def test_run_5(topology):
     """
     Check nsSSL3Ciphers: default
     Default ciphers are enabled.
@@ -325,7 +325,7 @@ def my_test_run_5(topology):
     connectWithOpenssl(topology, 'RC4-SHA', False)
     connectWithOpenssl(topology, 'AES256-SHA256', True)
 
-def my_test_run_6(topology):
+def test_run_6(topology):
     """
     Check nsSSL3Ciphers: +all,-TLS_RSA_WITH_AES_256_CBC_SHA256
     All ciphers are disabled.
@@ -346,7 +346,7 @@ def my_test_run_6(topology):
     connectWithOpenssl(topology, 'AES256-SHA256', False)
     connectWithOpenssl(topology, 'AES128-SHA', True)
 
-def my_test_run_7(topology):
+def test_run_7(topology):
     """
     Check nsSSL3Ciphers: -all,+rsa_rc4_128_md5
     All ciphers are disabled.
@@ -367,7 +367,7 @@ def my_test_run_7(topology):
     connectWithOpenssl(topology, 'AES256-SHA256', False)
     connectWithOpenssl(topology, 'RC4-MD5', True)
 
-def my_test_run_8(topology):
+def test_run_8(topology):
     """
     Check nsSSL3Ciphers: default + allowWeakCipher: off
     Strong Default ciphers are enabled.
@@ -387,7 +387,7 @@ def my_test_run_8(topology):
     connectWithOpenssl(topology, 'RC4-SHA', False)
     connectWithOpenssl(topology, 'AES256-SHA256', True)
 
-def my_test_run_9(topology):
+def test_run_9(topology):
     """
     Check no nsSSL3Ciphers
     Default ciphers are enabled.
@@ -410,7 +410,7 @@ def my_test_run_9(topology):
     connectWithOpenssl(topology, 'RC4-SHA', True)
     connectWithOpenssl(topology, 'AES256-SHA256', True)
 
-def my_test_run_10(topology):
+def test_run_10(topology):
     """
     Check nsSSL3Ciphers: -TLS_RSA_WITH_NULL_MD5,+TLS_RSA_WITH_RC4_128_MD5,
         +TLS_RSA_EXPORT_WITH_RC4_40_MD5,+TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5,
@@ -439,7 +439,7 @@ def my_test_run_10(topology):
     connectWithOpenssl(topology, 'RC4-MD5', True)
     connectWithOpenssl(topology, 'AES256-SHA256', False)
 
-def my_test_run_11(topology):
+def test_run_11(topology):
     """
     Check nsSSL3Ciphers: +fortezza
     SSL_GetImplementedCiphers does not return this as a secuire cipher suite
@@ -459,28 +459,6 @@ def my_test_run_11(topology):
     connectWithOpenssl(topology, 'AES256-SHA256', False)
 
 
-def test_ticket48194(topology):
-    '''
-    run_isolated is used to run these test cases independently of a test scheduler (xunit, py.test..)
-    To run isolated without py.test, you need to
-      - edit this file and comment '@pytest.fixture' line before 'topology' function.
-      - set the installation prefix
-      - run this program
-    '''
-    my_test_init(topology)
-    my_test_run_0(topology)
-    my_test_run_1(topology)
-    my_test_run_2(topology)
-    my_test_run_3(topology)
-    my_test_run_4(topology)
-    my_test_run_5(topology)
-    my_test_run_6(topology)
-    my_test_run_7(topology)
-    my_test_run_8(topology)
-    my_test_run_9(topology)
-    my_test_run_10(topology)
-    my_test_run_11(topology)
-
 if __name__ == '__main__':
     # Run isolated
     # -s for DEBUG mode

+ 4 - 4
dirsrvtests/tests/tickets/ticket48294_test.py

@@ -135,7 +135,7 @@ def _modrdn_entry(topology=None, entry_dn=None, new_rdn=None, del_old=0, new_sup
             ent = topology.standalone.getEntry(dn, ldap.SCOPE_BASE, myfilter)
 
 
-def _48294_init(topology):
+def test_48294_init(topology):
     """
     Set up Linked Attribute
     """
@@ -193,7 +193,7 @@ def _48294_init(topology):
     log.info('PASSED')
 
 
-def _48294_run_0(topology):
+def test_48294_run_0(topology):
     """
     Rename employee1 to employee2 and adjust the value of directReport by replace
     """
@@ -216,7 +216,7 @@ def _48294_run_0(topology):
     log.info('PASSED')
 
 
-def _48294_run_1(topology):
+def test_48294_run_1(topology):
     """
     Rename employee2 to employee3 and adjust the value of directReport by delete and add
     """
@@ -246,7 +246,7 @@ def _48294_run_1(topology):
     log.info('PASSED')
 
 
-def _48294_run_2(topology):
+def test_48294_run_2(topology):
     """
     Rename manager1 to manager2 and make sure the managed attribute value is updated
     """

+ 2 - 2
dirsrvtests/tests/tickets/ticket48295_test.py

@@ -113,7 +113,7 @@ def check_attr_val(topology, dn, attr, expected, revert):
         assert False
 
 
-def _48295_init(topology):
+def test_48295_init(topology):
     """
     Set up Linked Attribute
     """
@@ -164,7 +164,7 @@ def _48295_init(topology):
     log.info('PASSED')
 
 
-def _48295_run(topology):
+def test_48295_run(topology):
     """
     Add 2 linktypes - one exists, another does not
     """

+ 0 - 9
dirsrvtests/tests/tickets/ticket48745_test.py

@@ -167,14 +167,5 @@ def test_ticket48745_extensible_search_after_index(topology):
 if __name__ == '__main__':
     # Run isolated
     # -s for DEBUG mode
-#     global installation1_prefix
-#     installation1_prefix = None
-#     topo = topology(True)
-#     test_ticket48745_init(topo)
-#
-#     test_ticket48745_homeDirectory_indexed_cis(topo)
-#     test_ticket48745_homeDirectory_mixed_value(topo)
-#     test_ticket48745_extensible_search_after_index(topo)
-
     CURRENT_FILE = os.path.realpath(__file__)
     pytest.main("-s %s" % CURRENT_FILE)

+ 1 - 0
dirsrvtests/tests/tickets/ticket48784_test.py

@@ -428,6 +428,7 @@ def test_ticket48784(topology):
 
     log.info("Ticket 48784 - PASSED")
 
+
 if __name__ == '__main__':
     # Run isolated
     # -s for DEBUG mode