45 |
assert id.getURI() == lower_1 |
assert id.getURI() == lower_1 |
46 |
assert id.getContentType() == "application/rdf+xml" |
assert id.getContentType() == "application/rdf+xml" |
47 |
|
|
48 |
id2 = BlockId(id.getSha1(), id.getTigerTree(), |
id2 = BlockId(id.getContentType(), |
49 |
id.getContentType()) |
id.getSha1(), id.getTigerTree()) |
50 |
|
|
51 |
assert id2.getURI() == lower_1 |
assert id2.getURI() == lower_1 |
52 |
assert id == id2 |
assert id == id2 |
58 |
assert id != id3 |
assert id != id3 |
59 |
assert id.hashCode() != id3.hashCode() |
assert id.hashCode() != id3.hashCode() |
60 |
|
|
61 |
|
def testGetIdForData(): |
62 |
|
id_1 = BlockId(uri_1) |
63 |
|
id_2 = BlockId(uri_2) |
64 |
|
id_3 = BlockId(uri_3) |
65 |
|
get = BlockId.getIdForData |
66 |
|
|
67 |
|
assert id_2 == get('application/Octet-Stream', data_2) != id_3 |
68 |
|
assert id_3 == get('text/plain', data_3) != id_2 |
69 |
|
|
70 |
|
def check(id, data): |
71 |
|
try: id.check(data) |
72 |
|
except BlockId.WrongIdException: return 0 |
73 |
|
else: return 1 |
74 |
|
|
75 |
|
def testCheck(): |
76 |
|
id_1 = BlockId(uri_1) |
77 |
|
id_2 = BlockId(uri_2) |
78 |
|
id_3 = BlockId(uri_3) |
79 |
|
|
80 |
|
assert check(id_2, data_2) |
81 |
|
assert (not check(id_1, data_2)) and (not check(id_3, data_2)) |
82 |
|
|
83 |
|
assert check(id_3, data_3) |
84 |
|
assert (not check(id_1, data_3)) and (not check(id_2, data_3)) |