diff options
author | Matthew Newhook <matthew@zeroc.com> | 2015-03-18 12:58:16 -0230 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2015-03-18 12:58:16 -0230 |
commit | 9b7668c7c92cf9cb311fe444cdddb489cd2a219d (patch) | |
tree | 5016567c58c81f5654e9d01935e199c6bf4761d2 /demoscript/Freeze/library.py | |
parent | VS add-in & build updates: (diff) | |
download | ice-9b7668c7c92cf9cb311fe444cdddb489cd2a219d.tar.bz2 ice-9b7668c7c92cf9cb311fe444cdddb489cd2a219d.tar.xz ice-9b7668c7c92cf9cb311fe444cdddb489cd2a219d.zip |
Removed demos.
Moved demoscript to distribution.
Diffstat (limited to 'demoscript/Freeze/library.py')
-rwxr-xr-x | demoscript/Freeze/library.py | 138 |
1 files changed, 0 insertions, 138 deletions
diff --git a/demoscript/Freeze/library.py b/demoscript/Freeze/library.py deleted file mode 100755 index df5c3f5f7f7..00000000000 --- a/demoscript/Freeze/library.py +++ /dev/null @@ -1,138 +0,0 @@ -#!/usr/bin/env python -# ********************************************************************** -# -# Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -# -# This copy of Ice is licensed to you under the terms described in the -# ICE_LICENSE file included in this distribution. -# -# ********************************************************************** - -import sys -import Expect - -def dequote(s): - cur = 0 - end = len(s) - havequote = False - quote = None - items = [] - while cur < len(s): - if not quote: - if s[cur] == "'" or s[cur] == '"': - quote = s[cur] - start = cur+1 - else: - if s[cur] == quote: - items.append(s[start:cur]) - quote = None - cur = cur + 1 - return items - -def mkregexp(s): - s = s.replace('(', '\\(') - s = s.replace(')', '\\)') - s = s.replace('.', '\\.') - s = s.replace('+', '\\+') - s = s.replace('*', '\\*') - return s - -def run(client, server): - sys.stdout.write("populating database... ") - sys.stdout.flush() - f = open("books", "r") - books = [] - for l in f: - client.sendline(l) - client.expect('added new book') - isbn, title, author = dequote(l) - books.append((isbn, title, author)) - print("ok") - - byauthor = {} - for b in books: - isbn, title, author = b - if author not in byauthor: - byauthor[author] = [] - byauthor[author].append(b) - - sys.stdout.write("testing isbn... ") - sys.stdout.flush() - for b in books: - isbn, title, author = b - client.sendline('isbn %s' %(isbn)) - client.expect('current book is:') - client.expect('isbn: %s' %(isbn)) - client.expect('title: %s' %(mkregexp(title))) - client.expect('authors: %s' %(author)) - client.sendline('isbn 1000') - client.expect('no book with that') - print("ok") - - sys.stdout.write("testing authors... ") - sys.stdout.flush() - for a, bl in byauthor.items(): - client.sendline('authors "%s"' %(a)) - client.expect('number of books found: ([0-9]+)') - n = int(client.match.group(1)) - assert len(bl) == n - for i in range(0, n): - client.expect('current book is:') - client.expect('isbn: ([a-zA-Z0-9]+)\n') - findisbn = client.match.group(1) - nbl = [] - for b in bl: - isbn, title, author = b - if not findisbn: - nbl.append(b) - if isbn == findisbn: - findisbn = None - client.expect('title: %s' %(mkregexp(title))) - client.expect('authors: %s' %(author)) - bl = nbl - assert not findisbn - client.sendline('next') - client.expect('no current book') - assert len(bl) == 0 - client.sendline('authors foo') - client.expect('number of books found: 0') - client.expect('no current book') - print("ok") - - sys.stdout.write("testing rent/return... ") - sys.stdout.flush() - isbn, title, author = books[0] - client.sendline('isbn %s' % (isbn)) - client.expect('current book is:.*isbn.*\ntitle.*\nauthors') - client.sendline('rent matthew') - client.expect("the book is now rented by `matthew'") - client.sendline('current') - client.expect('rented: matthew') - client.sendline('rent john') - client.expect('the book has already been rented') - client.sendline('return') - client.expect('the book has been returned') - client.sendline('current') - try: - client.expect('rented:', timeout=2) - except Expect.TIMEOUT: - pass - print("ok") - - sys.stdout.write("testing remove... ") - sys.stdout.flush() - isbn, title, author = books[0] - client.sendline('isbn %s' % (isbn)) - client.expect('current book is:.*isbn.*\ntitle.*\nauthors') - client.sendline('remove') - client.expect('removed current book') - client.sendline('remove') - client.expect('current book no longer exists') - - client.sendline('shutdown') - if client != server: - server.waitTestSuccess() - client.sendline('exit') - client.waitTestSuccess() - - print("ok") |