def it_can_load_serialized_parts(self, _SerializedPart_, _walk_phys_parts): # test data -------------------- test_data = ( ('/part/name1.xml', 'app/vnd.type_1', 'reltype1', '<Part_1/>', 'srels_1'), ('/part/name2.xml', 'app/vnd.type_2', 'reltype2', '<Part_2/>', 'srels_2'), ) iter_vals = [(t[0], t[2], t[3], t[4]) for t in test_data] content_types = dict((t[0], t[1]) for t in test_data) # mockery ---------------------- phys_reader = Mock(name='phys_reader') pkg_srels = Mock(name='pkg_srels') _walk_phys_parts.return_value = iter_vals _SerializedPart_.side_effect = expected_sparts = (Mock(name='spart_1'), Mock(name='spart_2')) # exercise --------------------- retval = PackageReader._load_serialized_parts(phys_reader, pkg_srels, content_types) # verify ----------------------- expected_calls = [ call('/part/name1.xml', 'app/vnd.type_1', '<Part_1/>', 'reltype1', 'srels_1'), call('/part/name2.xml', 'app/vnd.type_2', '<Part_2/>', 'reltype2', 'srels_2'), ] assert _SerializedPart_.call_args_list == expected_calls assert retval == expected_sparts
def it_can_load_serialized_parts(self, _SerializedPart_, _walk_phys_parts): # test data -------------------- test_data = ( ('/part/name1.xml', 'app/vnd.type_1', 'reltype1', '<Part_1/>', 'srels_1'), ('/part/name2.xml', 'app/vnd.type_2', 'reltype2', '<Part_2/>', 'srels_2'), ) iter_vals = [(t[0], t[2], t[3], t[4]) for t in test_data] content_types = dict((t[0], t[1]) for t in test_data) # mockery ---------------------- phys_reader = Mock(name='phys_reader') pkg_srels = Mock(name='pkg_srels') _walk_phys_parts.return_value = iter_vals _SerializedPart_.side_effect = expected_sparts = ( Mock(name='spart_1'), Mock(name='spart_2') ) # exercise --------------------- retval = PackageReader._load_serialized_parts( phys_reader, pkg_srels, content_types ) # verify ----------------------- expected_calls = [ call('/part/name1.xml', 'app/vnd.type_1', '<Part_1/>', 'reltype1', 'srels_1'), call('/part/name2.xml', 'app/vnd.type_2', '<Part_2/>', 'reltype2', 'srels_2'), ] assert _SerializedPart_.call_args_list == expected_calls assert retval == expected_sparts