Browse Source

Ticket 49085 - Make a short topology fixture alias

Description: Modify create_test.py, so it will insert "topo" import alias
instead of long topology names like "topology_m1h1c1".
With it we have more readable code - 'topo.ms["master1"]'.

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

Reviewed by: mreynolds (Thanks!)
Simon Pichugin 8 years ago
parent
commit
9fcfb6c9d1
1 changed files with 4 additions and 4 deletions
  1. 4 4
      dirsrvtests/create_test.py

+ 4 - 4
dirsrvtests/create_test.py

@@ -212,7 +212,7 @@ if len(sys.argv) > 0:
 
 
     # Write the imports
     # Write the imports
     if my_topology[0]:
     if my_topology[0]:
-        topology_import = 'from lib389.topologies import {}\n'.format(my_topology[1])
+        topology_import = 'from lib389.topologies import {} as topo\n'.format(my_topology[1])
     else:
     else:
         topology_import = ''
         topology_import = ''
 
 
@@ -287,7 +287,7 @@ if len(sys.argv) > 0:
 
 
         # Write the 'topology function'
         # Write the 'topology function'
         TEST.write('@pytest.fixture(scope="module")\n')
         TEST.write('@pytest.fixture(scope="module")\n')
-        TEST.write('def {}(request):\n'.format(my_topology[1]))
+        TEST.write('def topo(request):\n')
 
 
         if repl_deployment:
         if repl_deployment:
             TEST.write('    """Create Replication Deployment"""\n')
             TEST.write('    """Create Replication Deployment"""\n')
@@ -656,14 +656,14 @@ if len(sys.argv) > 0:
 
 
     # Write the test function
     # Write the test function
     if ticket:
     if ticket:
-        TEST.write('def test_ticket{}({}):\n'.format(ticket, my_topology[1]))
+        TEST.write('def test_ticket{}(topo):\n'.format(ticket))
         TEST.write('    """Write your testcase here...\n\n')
         TEST.write('    """Write your testcase here...\n\n')
         TEST.write('    Also, if you need any testcase initialization,\n')
         TEST.write('    Also, if you need any testcase initialization,\n')
         TEST.write('    please, write additional fixture for that' +
         TEST.write('    please, write additional fixture for that' +
                    '(include finalizer).\n')
                    '(include finalizer).\n')
         TEST.write('    """\n\n')
         TEST.write('    """\n\n')
     else:
     else:
-        TEST.write('def test_something({}):\n'.format(my_topology[1]))
+        TEST.write('def test_something(topo):\n')
         TEST.write('    """Write a single test here...\n\n')
         TEST.write('    """Write a single test here...\n\n')
         TEST.write('    Also, if you need any test suite initialization,\n')
         TEST.write('    Also, if you need any test suite initialization,\n')
         TEST.write('    please, write additional fixture for that (including finalizer).\n'
         TEST.write('    please, write additional fixture for that (including finalizer).\n'