예제 #1
0
    def it_can_load_a_blob_from_a_file_path_to_help(self):
        path = absjoin(test_file_dir, "minimal.pptx")
        with open(path, "rb") as f:
            file_bytes = f.read()
        part = Part(None, None, None, None)

        assert part._blob_from_file(path) == file_bytes
예제 #2
0
 def it_can_be_constructed_by_PartFactory(self, load_fixture):
     partname_, content_type_, blob_, package_, __init_ = load_fixture
     part = Part.load(partname_, content_type_, blob_, package_)
     __init_.assert_called_once_with(
         partname_, content_type_, blob_, package_
     )
     assert isinstance(part, Part)
예제 #3
0
 def it_remembers_its_construction_state(self):
     partname, content_type, blob, element, package = (
         Mock(name='partname'), Mock(name='content_type'),
         Mock(name='blob'), None, Mock(name='package')
     )
     part = Part(partname, content_type, blob, element, package)
     assert part.partname == partname
     assert part.content_type == content_type
     assert part.blob == blob
     assert part.package == package
 def part(self):
     part = Part(None, None)
     return part
 def package_get_fixture(self, package_):
     part = Part(None, None, None, package_)
     return part, package_
 def content_type_fixture(self):
     content_type = "content/type"
     part = Part(None, content_type, None, None)
     return part, content_type
 def blob_fixture(self, blob_):
     part = Part(None, None, blob_, None)
     return part, blob_
 def it_can_change_its_blob(self):
     part, new_blob = Part(None, None, "xyz", None), "foobar"
     part.blob = new_blob
     assert part.blob == new_blob
 def rels_fixture(self, Relationships_, partname_, rels_):
     part = Part(partname_, None)
     return part, Relationships_, partname_, rels_
예제 #10
0
 def it_has_a_rels_collection_initialized_on_first_reference(
         self, RelationshipCollection_):
     partname = PackURI('/foo/bar.xml')
     part = Part(partname, None, None)
     assert part.rels is RelationshipCollection_.return_value
     RelationshipCollection_.assert_called_once_with(partname.baseURI)
예제 #11
0
 def it_can_change_its_blob(self):
     part, new_blob = Part(None, None, 'xyz', None), 'foobar'
     part.blob = new_blob
     assert part.blob == new_blob
예제 #12
0
 def it_can_load_a_blob_from_a_file_like_object_to_help(self):
     part = Part(None, None, None, None)
     assert part._blob_from_file(io.BytesIO(b"012345")) == b"012345"
예제 #13
0
 def it_can_change_its_blob(self):
     part, new_blob = Part(None, None, 'xyz', None), 'foobar'
     part.blob = new_blob
     assert part.blob == new_blob
 def partname_get_fixture(self):
     partname = PackURI("/part/name")
     part = Part(partname, None, None, None)
     return part, partname
예제 #15
0
 def part(self):
     partname = PackURI('/foo/bar.xml')
     part = Part(partname, None, None)
     return part
 def partname_set_fixture(self):
     old_partname = PackURI("/old/part/name")
     new_partname = PackURI("/new/part/name")
     part = Part(old_partname, None, None, None)
     return part, new_partname
 def it_can_be_constructed_by_PartFactory(self, load_fixture):
     partname_, content_type_, blob_, package_, __init_ = load_fixture
     part = Part.load(partname_, content_type_, blob_, package_)
     __init_.assert_called_once_with(partname_, content_type_, blob_, package_)
     assert isinstance(part, Part)
 def part(self):
     return Part(None, None)
예제 #19
0
 def it_can_change_its_blob(self):
     part, new_blob = Part(None, None, "xyz", None), "foobar"
     part.blob = new_blob
     assert part.blob == new_blob