1120
1120
def test_save_file_ignores_invalid_icons(self):
1121
1121
path = self.use_context(temp_dir())
1122
1123
with file(join(path, 'icon.svg'), 'w') as f:
1124
1125
files = self.save_files(path)
1125
1126
self.assertEqual([], files)
1127
# No width or height provided.
1128
with file(join(path, 'icon.svg'), 'w') as f:
1129
f.write('<?xml version="1.0"?><svg></svg>')
1130
files = self.save_files(path)
1131
self.assertEqual([], files)
1133
def test_adds_viewbox_to_icons(self):
1134
path = self.use_context(temp_dir())
1135
with file(join(path, 'icon.svg'), 'w') as f:
1136
f.write('<?xml version="1.0"?><svg width="10" height="10"></svg>')
1137
self.save_files(path)
1138
icon_id = self.base_fileid + quote_key('icon.svg')
1139
cf = CharmFileSet.get_by_id(self.fs, icon_id)
1141
"<?xml version='1.0' encoding='UTF-8'?>\n" \
1142
+ '<svg height="10" viewBox="0 0 10 10" width="10" />',
1127
1145
def test_provides_content_type(self):
1128
1146
path = self.use_context(temp_dir())
1129
1147
with file(join(path, 'icon.svg'), 'w') as f:
1130
f.write('<?xml version="1.0"?><svg></svg>')
1148
f.write('<?xml version="1.0"?><svg width="10" height="10"></svg>')
1131
1149
with file(join(path, 'readme.txt'), 'w') as f:
1133
1151
self.save_files(path)