• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IIIF / image-validator / 12285728456

11 Dec 2024 10:07PM UTC coverage: 40.498% (+2.5%) from 37.982%
12285728456

Pull #106

github

glenrobson
Moving to updating pypi via github actions
Pull Request #106: Adding github actions

699 of 1726 relevant lines covered (40.5%)

2.02 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

36.67
/iiif_validator/tests/format_jp2.py
1
from .test import BaseTest, ValidatorError
5✔
2
import magic, urllib
5✔
3

4
try:
5✔
5
    # python3
6
    from urllib.request import Request, urlopen, HTTPError
5✔
7
except ImportError:
×
8
    # fall back to python2
9
    from urllib2 import Request, urlopen, HTTPError
×
10

11
class Test_Format_Jp2(BaseTest):
5✔
12
    label = 'JPEG2000 format'
5✔
13
    level = {u'3.0': 3, u'2.0': 3, u'1.0': 2, u'1.1': 3}
5✔
14
    category = 6
5✔
15
    versions = [u'1.0', u'1.1', u'2.0', u'3.0']
5✔
16
    validationInfo = None
5✔
17

18
    def run(self, result):
5✔
19

20
        params = {'format': 'jp2'}
×
21
        url = result.make_url(params)
×
22
        # Need as plain string for magic
23
        try:
×
24
            wh = urlopen(url)
×
25
        except HTTPError as error:    
×
26
            raise ValidatorError('format', 'http response code: {}'.format(error.code), url, result, 'Failed to retrieve jp2, got response code {}'.format(error.code))
×
27
        img = wh.read()
×
28
        wh.close()
×
29
        # check response code before checking the file
30
        if wh.getcode() != 200:
×
31
            raise ValidatorError('format', 'http response code: {}'.format(wh.getcode()), url, result, 'Failed to retrieve jp2, got response code {}'.format(wh.getcode()))
×
32

33
        with magic.Magic() as m:
×
34
            print ('test')
×
35
            info = m.id_buffer(img)
×
36
            if not info.startswith('JPEG 2000'):
×
37
                # Not JP2
38
                raise ValidatorError('format', info, 'JPEG 2000', result)
×
39
            else:
40
                result.tests.append('format')
×
41
                return result
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc