~jcsackett/charmworld/bac-tag-constraints

« back to all changes in this revision

Viewing changes to charmworld/tests/test_models.py

  • Committer: Matthew Scott
  • Date: 2013-08-15 18:54:39 UTC
  • mto: This revision was merged to the branch mainline in revision 350.
  • Revision ID: matthew.scott@canonical.com-20130815185439-jdjts5pjtaafq2b0
Add viewBox to icons; tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
1119
1119
 
1120
1120
    def test_save_file_ignores_invalid_icons(self):
1121
1121
        path = self.use_context(temp_dir())
 
1122
        # Not an SVG.
1122
1123
        with file(join(path, 'icon.svg'), 'w') as f:
1123
1124
            f.write('foo')
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)
 
1132
 
 
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)
 
1140
        self.assertEqual(
 
1141
                "<?xml version='1.0' encoding='UTF-8'?>\n" \
 
1142
                    + '<svg height="10" viewBox="0 0 10 10" width="10" />',
 
1143
                cf.read())
1126
1144
 
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:
1132
1150
            f.write('foo')
1133
1151
        self.save_files(path)