示例#1
0
文件: npktest.py 项目: lqez/pynpk
 def test_export_entity(self, tmpdir):
     pack = npk.package(filename, key)
     for entity in pack.all():
         export_filename = str(tmpdir.join(entity.name()))
         entity.export(export_filename)
         assert open(export_filename).read() == open(sample).read()
     pack.close()
示例#2
0
文件: npktest.py 项目: lqez/pynpk
 def test_iterate_entities(self):
     pack = npk.package(filename, key)
     entities = pack.all()
     entities_expected = ['sample.txt', 'tea.txt', 'zip.txt', 'zipntea.txt']
     assert len(entities) == 4
     assert set(sorted([str(x) for x in entities])) == set(sorted(entities_expected))
     pack.close()
示例#3
0
文件: npktest.py 项目: lqez/pynpk
 def test_get_entity_fail(self):
     pack = npk.package(filename, key)
     with raises(npk.EntityNotFound):
         pack.get("notfound.42")
     pack.close()
示例#4
0
文件: npktest.py 项目: lqez/pynpk
 def test_get_entity(self):
     pack = npk.package(filename, key)
     for entity in pack.all():
         assert entity.read() == open(sample).read()
     pack.close()
示例#5
0
文件: npktest.py 项目: lqez/pynpk
 def test_open_package_fail(self):
     with raises(npk.FailToOpenPackage):
         npk.package(filename, reversed(key))
示例#6
0
文件: npktest.py 项目: lqez/pynpk
 def test_create_package(self):
     pack = npk.package()
     pack.add(sample)
     pack.save("test.npk")
     pack.close()
示例#7
0
文件: npktest.py 项目: lqez/pynpk
 def test_open_package(self):
     pack = npk.package(filename, key)
     pack.close()