Browse Source

[1290] additional comments and info, and a compound step example

Jelte Jansen 13 years ago
parent
commit
d63457baaa

+ 10 - 5
tests/lettuce/features/bind10_control.py

@@ -30,7 +30,7 @@ def wait_for_output_lines(lines, examine_past = True):
             if output.find(line) != -1:
                 return line
 
-@step(u'start bind10(?: with configuration ([\w.]+))?')
+@step('start bind10(?: with configuration ([\w.]+))?')
 def start_bind10(step, config_file):
     args = [ 'bind10', '-v' ]
     if config_file is not None:
@@ -47,19 +47,24 @@ def start_bind10(step, config_file):
                                            "BIND10_STARTUP_ERROR"])
     assert message == "BIND10_STARTUP_COMPLETE"
 
-@step(u'wait for bind10 auth to start')
+@step('wait for bind10 auth to start')
 def wait_for_auth(step):
     world.wait_for_output_lines(['AUTH_SERVER_STARTED'])
 
-@step(u'wait for log message (\w+)')
+@step('have bind10 running(?: with configuration ([\w.]+))?')
+def have_bind10_running(step, config_file):
+    step.given('start bind10 with configuration ' + config_file)
+    step.given('wait for bind10 auth to start')
+
+@step('wait for log message (\w+)')
 def wait_for_message(step, message):
     world.wait_for_output_lines([message], False)
 
-@step(u'stop bind10')
+@step('stop bind10')
 def stop_the_server(step):
     world.shutdown_server()
 
-@step(u'set bind10 configuration (\S+) to (.*)')
+@step('set bind10 configuration (\S+) to (.*)')
 def set_config_command(step, name, value):
     bindctl = subprocess.Popen(['bindctl'], 1, None, subprocess.PIPE,
                                subprocess.PIPE, None)

+ 4 - 4
tests/lettuce/features/querying.py

@@ -106,8 +106,8 @@ class QueryResult(object):
     def parse_footer(self, line):
         pass
 
-@step(u'A query for ([\w.]+) (?:type ([A-Z]+) )?(?:class ([A-Z]+) )?' +
-       '(?:to ([^:]+)(?::([0-9]+))? )?should have rcode ([\w.]+)')
+@step('A query for ([\w.]+) (?:type ([A-Z]+) )?(?:class ([A-Z]+) )?' +
+      '(?:to ([^:]+)(?::([0-9]+))? )?should have rcode ([\w.]+)')
 def query(step, query_name, qtype, qclass, addr, port, rcode):
     if qtype is None:
         qtype = "A"
@@ -121,7 +121,7 @@ def query(step, query_name, qtype, qclass, addr, port, rcode):
     assert query_result.rcode == rcode, "Got " + query_result.rcode
     world.last_query_result = query_result
 
-@step(u'The SOA serial for ([\w.]+) should be ([0-9]+)')
+@step('The SOA serial for ([\w.]+) should be ([0-9]+)')
 def query_soa(step, query_name, serial):
     query_result = QueryResult(query_name, "SOA", "IN", "127.0.0.1", "47806")
     assert "NOERROR" == query_result.rcode,\
@@ -132,7 +132,7 @@ def query_soa(step, query_name, serial):
     assert serial == soa_parts[6],\
         "Got SOA serial " + soa_parts[6] + ", expected " + serial
 
-@step(u'last query should have (\S+) (.+)')
+@step('last query should have (\S+) (.+)')
 def check_last_query(step, item, value):
     assert world.last_query_result is not None
     assert item in world.last_query_result.__dict__

+ 15 - 2
tests/lettuce/features/server_from_sqlite3.feature

@@ -14,11 +14,15 @@ Feature: SQLite3 backend
         # This scenario performs a number of queries and inspects the results
         # This is not only to test, but also to show the different options
         # we have to inspect the data
-        When I start bind10 with configuration example.org.config
-        Then wait for bind10 auth to start
 
+        # This is a compound statement that starts and waits for the
+        # started message
+        Given I have bind10 running with configuration example.org.config
+
+        # A simple query that is not examined further
         A query for www.example.com should have rcode REFUSED
 
+        # A query where we look at some of the result properties
         A query for www.example.org should have rcode NOERROR
         The last query should have qdcount 1
         The last query should have ancount 1
@@ -26,6 +30,7 @@ Feature: SQLite3 backend
         The last query should have adcount 0
         The SOA serial for example.org should be 1234
 
+        # Another query where we look at some of the result properties
         A query for doesnotexist.example.org should have rcode NXDOMAIN
         The last query should have qdcount 1
         The last query should have ancount 0
@@ -36,6 +41,8 @@ Feature: SQLite3 backend
         A query for www.example.org type TXT should have rcode NOERROR
         The last query should have ancount 0
 
+        # Some queries where we specify more details about what to send and
+        # where
         A query for www.example.org class CH should have rcode REFUSED
         A query for www.example.org to 127.0.0.1 should have rcode NOERROR
         A query for www.example.org to 127.0.0.1:47806 should have rcode NOERROR
@@ -48,6 +55,12 @@ Feature: SQLite3 backend
         # for instance auth could still be serving the old zone when we send
         # the new query, or already respond from the new database.
         # Therefore we wait for specific log messages after each operation
+        #
+        # This scenario outlines every single step, and does not use
+        # 'steps of steps' (e.g. Given I have bind10 running)
+        # We can do that but as an example this is probably better to learn
+        # the system
+
         When I start bind10 with configuration example.org.config
         Then wait for bind10 auth to start
         Wait for log message CMDCTL_STARTED

+ 2 - 2
tests/lettuce/features/steps.py

@@ -26,12 +26,12 @@ def cleanup(feature):
     world.shutdown_server()
     world.bind10_output = []
 
-@step(u'Given I have no database')
+@step('Given I have no database')
 def given_i_have_no_database(step):
     if os.path.exists("test.db"):
         os.remove("test.db")
 
-@step(u'I should see a database file')
+@step('I should see a database file')
 def i_should_see_a_database_file(step):
     assert os.path.exists("test.db")
     os.remove("test.db")