33 |
def testAddBlock(): s.testAddBlock(p) |
def testAddBlock(): s.testAddBlock(p) |
34 |
def testGetNonexistent(): s.testGetNonexistent(p) |
def testGetNonexistent(): s.testGetNonexistent(p) |
35 |
|
|
36 |
|
def testGetBlockWithBadId(): |
37 |
|
""" |
38 |
|
Put a block with a bad id into the directory, then load it |
39 |
|
and check that an exception is thrown. |
40 |
|
""" |
41 |
|
|
42 |
|
id = gzz.storm.BlockId('storm:block:01' + 40*'A') |
43 |
|
|
44 |
|
file = java.io.File(dir, "b_01" + 40*"A") |
45 |
|
f = open(file.getPath(), 'w') |
46 |
|
f.write("Content-Type: text/plain\r\n\r\nFOO"); |
47 |
|
f.close() |
48 |
|
|
49 |
|
try: |
50 |
|
block = p.get(id) |
51 |
|
i = block.getInputStream() |
52 |
|
while i.read() >= 0: pass |
53 |
|
i.close() |
54 |
|
except gzz.storm.BlockId.WrongIdException: |
55 |
|
pass |
56 |
|
else: |
57 |
|
assert 0, "Id not checked" |
58 |
|
|
59 |
def tearDown(): |
def tearDown(): |
60 |
gzz.util.TempFileUtil.deltree(dir) |
gzz.util.TempFileUtil.deltree(dir) |
61 |
|
|