summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2017-04-13 21:26:04 +0300
committerLars Wirzenius <liw@liw.fi>2017-04-13 21:26:04 +0300
commitc8922f0e8641cb581f2d021e3aee7728ec3b47db (patch)
tree6578f5c46b092c7acc1d3bf02588bc77796e989d
parenta7dc5ff2e9369498c74326735f57e409a519e5ca (diff)
downloadserver-yarns-c8922f0e8641cb581f2d021e3aee7728ec3b47db.tar.gz
Move most imports into lib.py
-rw-r--r--900-implements.yarn18
-rw-r--r--lib.py6
2 files changed, 8 insertions, 16 deletions
diff --git a/900-implements.yarn b/900-implements.yarn
index 7e6ef72..035c33a 100644
--- a/900-implements.yarn
+++ b/900-implements.yarn
@@ -3,14 +3,12 @@
## Server aliases
IMPLEMENTS GIVEN server is also known as (\S+)
- import yarnhelper
h = yarnhelper.YarnHelper()
h.set_variable('ALIAS', h.get_next_match())
## HTTP requests
IMPLEMENTS WHEN user fetches (\S+)
- import os, yarnhelper
h = yarnhelper.YarnHelper()
address = os.environ['ADDRESS']
url = h.get_next_match()
@@ -19,14 +17,12 @@
h.set_variable('http_body', body)
IMPLEMENTS THEN HTTP status is (\d+)
- import yarnhelper
h = yarnhelper.YarnHelper()
expected = h.get_variable('http_status')
actual = int(h.get_next_match())
h.assertEqual(expected, actual)
IMPLEMENTS THEN HTTP body matches "(.*)"
- import re, sys, yarnhelper
h = yarnhelper.YarnHelper()
body = h.get_variable('http_body')
sys.stdout.write('Body:\n{}'.format(repr(body)))
@@ -37,7 +33,6 @@
## Running commands and checking results
IMPLEMENTS WHEN user runs Gitano (.*)
- import os, re, cliapp, yarnhelper
h = yarnhelper.YarnHelper()
address = os.environ['ADDRESS']
cmd = h.get_next_match()
@@ -49,7 +44,6 @@
h.set_variable('stderr', err)
IMPLEMENTS WHEN user clones the (\S+) repository over git://
- import os, re, cliapp, yarnhelper
h = yarnhelper.YarnHelper()
address = os.environ['ADDRESS']
repo = h.get_next_match()
@@ -62,13 +56,11 @@
h.set_variable('stderr', err)
IMPLEMENTS THEN exit code is (\d+)
- import yarnhelper
h = yarnhelper.YarnHelper()
code = h.get_next_match()
h.assertEqual(h.get_variable('exit'), int(code))
IMPLEMENTS THEN standard output matches "(.+)"
- import re, cliapp, yarnhelper
h = yarnhelper.YarnHelper()
pattern = h.get_next_match()
stdout = h.get_variable('stdout')
@@ -79,7 +71,6 @@
h.assertNotEqual(m, None)
IMPLEMENTS THEN standard error matches "(.+)"
- import re, cliapp, yarnhelper
h = yarnhelper.YarnHelper()
pattern = h.get_next_match()
stderr = h.get_variable('stderr')
@@ -94,7 +85,6 @@
## Generate a random number
IMPLEMENTS GIVEN large random number (\S+)
- import yarnhelper, random
h = yarnhelper.YarnHelper()
varname = h.get_next_match()
mini = 2**32
@@ -106,7 +96,7 @@
## Send mail over SMTP+TLS
IMPLEMENTS WHEN someone sends mail to (\S+) with subject \$(\S+)
- import os, smtplib, sys, yarnhelper
+ import smtplib
h = yarnhelper.YarnHelper()
to_addr = h.get_next_match()
subject_key = h.get_next_match()
@@ -125,7 +115,6 @@
## Check for a mail in a mailbox
IMPLEMENTS THEN mailbox of (\S+) has a mail with subject \$(\S+)
- import os, yarnhelper
h = yarnhelper.YarnHelper()
user = h.get_next_match()
subject_key = h.get_next_match()
@@ -146,7 +135,6 @@
## Delete mails
IMPLEMENTS THEN mails for (\S+) with subject \$(\S+) get deleted
- import os, yarnhelper
h = yarnhelper.YarnHelper()
user = h.get_next_match()
subject_key = h.get_next_match()
@@ -165,13 +153,11 @@
## Run sequence of SMTP commands, check SMTP status
IMPLEMENTS WHEN client SMTP authenticates as (\S+)
- import yarnhelper
h = yarnhelper.YarnHelper()
user = h.get_next_match()
h.set_variable('smtp_username', user)
IMPLEMENTS WHEN client sends (.*)
- import yarnhelper
h = yarnhelper.YarnHelper()
command = h.get_next_match()
smtp_commands = h.get_variable('smtp_commands', [])
@@ -179,7 +165,7 @@
h.set_variable('smtp_commands', smtp_commands)
IMPLEMENTS THEN SMTP status code is (\d+)
- import os, smtplib, yarnhelper
+ import smtplib
h = yarnhelper.YarnHelper()
wanted_status = int(h.get_next_match())
smtp_commands = h.get_variable('smtp_commands')
diff --git a/lib.py b/lib.py
index 56eea02..45369e8 100644
--- a/lib.py
+++ b/lib.py
@@ -1,7 +1,13 @@
import os
+import random
+import re
+import sys
+import cliapp
import yarnutils
+import yarnhelper
+
srcdir = os.environ['SRCDIR']
datadir = os.environ['DATADIR']