def test_code_re(self): validate_size({'code': 'small', 'wxh': '100x100'}) validate_size({'code': 's', 'wxh': '100x100'}) validate_size({'code': '2', 'wxh': '100x100'}) self.assertRaises(SizeError, validate_size, { 'code': ' ', 'wxh': '100x100' }) self.assertRaises(SizeError, validate_size, { 'code': '&', 'wxh': '100x100' }) self.assertRaises(SizeError, validate_size, { 'code': 's ', 'wxh': '100x100' }) self.assertRaises(SizeError, validate_size, { 'code': 's!', 'wxh': '100x100' }) self.assertRaises(SizeError, validate_size, { 'code': '2+', 'wxh': '100x100' })
def test_wxh_re(self): validate_size({'code': 'small', 'wxh': '100x100'}) validate_size({'code': 'small', 'wxh': '5x5'}) validate_size({'code': 'small', 'wxh': '1024x512'}) # '100x' 'x100' now supported for fixed width, fixed heigh validate_size({'code': 'fixedwidth', 'wxh': '100x'}) validate_size({'code': 'fixedheight', 'wxh': 'x100'}) self.assertRaises(SizeError, validate_size, {'code': 'small', 'wxh': ''}) self.assertRaises(SizeError, validate_size, {'code': 'small', 'wxh': 'x'}) self.assertRaises(SizeError, validate_size, {'code': 'small', 'wxh': '100xx100'}) self.assertRaises(SizeError, validate_size, {'code': 'small', 'wxh': 'x100x100'}) self.assertRaises(SizeError, validate_size, {'code': 'small', 'wxh': '100x100x'}) self.assertRaises(SizeError, validate_size, {'code': 'small', 'wxh': '1-0x100'}) self.assertRaises(SizeError, validate_size, {'code': 'small', 'wxh': '100x 100'})
def test_wxh_re(self): validate_size({'code': 'small', 'wxh': '100x100'}) validate_size({'code': 'small', 'wxh': '5x5'}) validate_size({'code': 'small', 'wxh': '1024x512'}) # '100x' 'x100' now supported for fixed width, fixed heigh validate_size({'code': 'fixedwidth', 'wxh': '100x'}) validate_size({'code': 'fixedheight', 'wxh': 'x100'}) self.assertRaises(SizeError, validate_size, { 'code': 'small', 'wxh': '' }) self.assertRaises(SizeError, validate_size, { 'code': 'small', 'wxh': 'x' }) self.assertRaises(SizeError, validate_size, { 'code': 'small', 'wxh': '100xx100' }) self.assertRaises(SizeError, validate_size, { 'code': 'small', 'wxh': 'x100x100' }) self.assertRaises(SizeError, validate_size, { 'code': 'small', 'wxh': '100x100x' }) self.assertRaises(SizeError, validate_size, { 'code': 'small', 'wxh': '1-0x100' }) self.assertRaises(SizeError, validate_size, { 'code': 'small', 'wxh': '100x 100' })
def test_code_re(self): validate_size({'code': 'small', 'wxh': '100x100'}) validate_size({'code': 's', 'wxh': '100x100'}) validate_size({'code': '2', 'wxh': '100x100'}) self.assertRaises(SizeError, validate_size, {'code': ' ', 'wxh': '100x100'}) self.assertRaises(SizeError, validate_size, {'code': '&', 'wxh': '100x100'}) self.assertRaises(SizeError, validate_size, {'code': 's ', 'wxh': '100x100'}) self.assertRaises(SizeError, validate_size, {'code': 's!', 'wxh': '100x100'}) self.assertRaises(SizeError, validate_size, {'code': '2+', 'wxh': '100x100'})
def test_resize_valid(self): validate_size({'code': 'small', 'wxh': '100x100', 'resize': 'crop'}) validate_size({'code': 'small', 'wxh': '100x100', 'resize': 'scale'})
def test_resize_optional(self): validate_size({'code': 'small', 'wxh': '100x100'})
def test_code_wxh_required(self): validate_size({'code': 'small', 'wxh': '100x100'}) self.assertRaises(SizeError, validate_size, {'code': 'small'}) self.assertRaises(SizeError, validate_size, {'wxh': '100x100'}) self.assertRaises(SizeError, validate_size, {})