Esempio n. 1
0
 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()
Esempio n. 2
0
 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()
Esempio n. 3
0
 def test_get_entity_fail(self):
     pack = npk.package(filename, key)
     with raises(npk.EntityNotFound):
         pack.get("notfound.42")
     pack.close()
Esempio n. 4
0
 def test_get_entity(self):
     pack = npk.package(filename, key)
     for entity in pack.all():
         assert entity.read() == open(sample).read()
     pack.close()
Esempio n. 5
0
 def test_open_package_fail(self):
     with raises(npk.FailToOpenPackage):
         npk.package(filename, reversed(key))
Esempio n. 6
0
 def test_create_package(self):
     pack = npk.package()
     pack.add(sample)
     pack.save("test.npk")
     pack.close()
Esempio n. 7
0
 def test_open_package(self):
     pack = npk.package(filename, key)
     pack.close()