summaryrefslogtreecommitdiff
path: root/yarns/900.yarn
diff options
context:
space:
mode:
Diffstat (limited to 'yarns/900.yarn')
-rw-r--r--yarns/900.yarn96
1 files changed, 0 insertions, 96 deletions
diff --git a/yarns/900.yarn b/yarns/900.yarn
deleted file mode 100644
index 8ee31f3..0000000
--- a/yarns/900.yarn
+++ /dev/null
@@ -1,96 +0,0 @@
-# Scenario step implementations
-
-# Manage controller instance
-
- IMPLEMENTS GIVEN a running controller instance
- controller = os.path.join(srcdir, 'controller')
- cliapp.runcmd(
- ['/usr/sbin/daemonize', '-c.',
- controller, '--debug', '--pid-file=pid',
- '--port-file=port', '--projects=ick.ick', '--log=log'])
- vars['pid'] = cat('pid').strip()
- vars['port'] = cat('port').strip()
-
- IMPLEMENTS FINALLY stop controller instance
- import signal
- print 'killing process', repr(vars['pid'])
- os.kill(int(vars['pid']), signal.SIGTERM)
-
-
-## Git repositories
-
- IMPLEMENTS GIVEN a git repo (\S+) with file (\S+) containing "(.+)"
- repo = yarnutils.get_next_match()
- filename = yarnutils.get_next_match()
- content = yarnutils.get_next_match()
- pathname = os.path.join(repo, filename)
- os.mkdir(repo)
- git(repo, 'init', '.')
- git(repo, 'config', 'user.email', 'user@example.com')
- git(repo, 'config', 'user.name', 'J. Random User')
- write(pathname, unescape(content))
- git(repo, 'add', '.')
- git(repo, 'commit', '-minitial')
-
-## Controller configuration
-
- IMPLEMENTS GIVEN a project (\S+), using (\S+), publishing to (\S+)
- project = yarnutils.get_next_match()
- repo = yarnutils.get_next_match()
-
- if os.path.exists('ick.ick'):
- config = yaml.safe_load(open('ick.ick'))
- else:
- config = {
- 'projects': {}
- }
- config['projects'][project] = {
- 'git': repo,
- 'shell_steps': [
- 'ikiwiki --build',
- 'rsync',
- ],
- }
- write('ick.ick', yaml.safe_dump(config))
-
-## API use
-
- IMPLEMENTS WHEN (user|worker manager|git server) calls (\S+) (\S+)
- who = yarnutils.get_next_match()
- method = yarnutils.get_next_match()
- path = yarnutils.get_next_match()
- url = controller_url(vars['port'], path)
- vars['status'], vars['body'] = request(method, url)
-
- IMPLEMENTS WHEN worker manager calls (\S+) (\S+), with JSON body '(.+)'
- method = yarnutils.get_next_match()
- path = yarnutils.get_next_match()
- body_text = yarnutils.get_next_match()
- url = controller_url(vars['port'], path)
- body = parse_json(body_text)
- vars['status'], vars['body'] = request(method, url, body=body_text)
-
- IMPLEMENTS THEN response has status (\d+), and an empty body
- status = yarnutils.get_next_match()
- yarnutils.assertEqual(int(status), int(vars['status']))
- yarnutils.assertEqual(vars['body'], '')
-
- IMPLEMENTS THEN response has status (\d+), and text body "(.+)"
- status = yarnutils.get_next_match()
- bodypat = yarnutils.get_next_match()
- yarnutils.assertEqual(int(status), int(vars['status']))
- yarnutils.assertEqual(vars['body'], unescape(bodypat) )
-
- IMPLEMENTS THEN response has status (\d+), and JSON body "(.+)"
- status = yarnutils.get_next_match()
- bodytext = yarnutils.get_next_match()
- print 'varsbody:', repr(vars['body'])
- print 'bodytext:', repr(bodytext)
- bodyjson = parse_json(bodytext)
- print 'bodyjson:', repr(bodyjson)
- yarnutils.assertEqual(int(status), int(vars['status']))
- yarnutils.assertEqual(parse_json(vars['body']), parse_json(bodytext) )
-
- IMPLEMENTS THEN response has status (\d+)
- status = yarnutils.get_next_match()
- yarnutils.assertEqual(int(status), int(vars['status']))