Esempio n. 1
0
    def setUp(self):
        # Load schemas for test
        from django.core.management import call_command
        call_command('loaddata', 'as_schemas')
        self.experiment = None
        Location.force_initialize()

        try:
            self.user = User.objects.get(username='******')
        except User.DoesNotExist:
            self.user = User.objects.create_user('test', '', 'test')
            self.user.save()

        self.userprofile = UserProfile(user=self.user).save()

        filename = path.join(path.abspath(path.dirname(__file__)),
                             './METS_test.xml')

        expid, sync_path = _registerExperimentDocument(filename,
                                                       self.user,
                                                       expid=None)
        ensure(
            sync_path.startswith(settings.SYNC_TEMP_PATH), True,
            "Sync path should be influenced by SYNC_TEMP_PATH: %s" % sync_path)
        self.experiment = Experiment.objects.get(pk=expid)
        self.sync_path = sync_path
Esempio n. 2
0
def step_impl(context):
    for addr in context.testdata['addresses']:
        if context.MyAddress.add_address(addr) is True:
            #Asserting adding is complete
            ensure(
                context.MyAddress.is_address_existed(addr['alias']) == True,
                True, "Fail to add new address %s" % addr['alias'])
Esempio n. 3
0
 def testForbiddenWithoutLogin(self):
     client = Client()
     response = client.get(self._get_staging_url())
     # Expect a redirect to login
     expect(response.status_code).to_equal(302)
     login_url = reverse("tardis.tardis_portal.views.login")
     ensure(login_url in response["Location"], True, "Redirect URL was not to login.")
Esempio n. 4
0
    def test_ensures_suitable_license(self):
        suitableCombinations = (
            (Experiment.PUBLIC_ACCESS_NONE, ''),
            (Experiment.PUBLIC_ACCESS_METADATA, ''),
            (Experiment.PUBLIC_ACCESS_NONE, self.restrictiveLicense.id),
            (Experiment.PUBLIC_ACCESS_METADATA, self.restrictiveLicense.id),
            (Experiment.PUBLIC_ACCESS_FULL, self.permissiveLicense.id),
        )
        unsuitableCombinations = (
            (Experiment.PUBLIC_ACCESS_NONE, self.permissiveLicense.id),
            (Experiment.PUBLIC_ACCESS_METADATA, self.permissiveLicense.id),
            (Experiment.PUBLIC_ACCESS_METADATA, self.inactiveLicense.id),
            (Experiment.PUBLIC_ACCESS_FULL, self.inactiveLicense.id),
            (Experiment.PUBLIC_ACCESS_FULL, ''),
            (Experiment.PUBLIC_ACCESS_FULL, self.restrictiveLicense.id),
        )

        # Check we accept valid input
        for public_access, license_id in suitableCombinations:
            print "Suitable combination: %d %s" % (public_access, license_id)
            data = {'public_access': str(public_access),
                    'license': license_id }
            form = RightsForm(data)
            ensure(form.is_valid(), True, form.errors);

        # Check we reject invalid input
        for public_access, license_id in unsuitableCombinations:
            print "Unsuitable combination: %d %s" % (public_access, license_id)
            data = {'public_access': str(public_access),
                    'license': license_id }
            form = RightsForm(data)
            ensure(form.is_valid(), False);
Esempio n. 5
0
 def testCanCreate(self):
     params = {
         'type': 'website',
         'identifier': 'https://www.google.com/',
         'title': 'Google',
         'notes': 'This is a note.'
     }
     response = self.client.post(reverse('tardis.apps.related_info.views.' +
                                         'list_or_create_related_info',
                                         args=[self.experiment.id]),
                                 data=json.dumps(params),
                                 content_type='application/json')
     # Check that content reports as created, returns the created object
     expect(response.status_code).to_equal(201)
     obj = json.loads(response.content)
     ensure(isinstance(obj['id'], int),
            True,
            message='Created object should have an ID.')
     for k in params.keys():
         expect(obj[k]).to_equal(params[k])
     # Check that creation really did persist
     response = self.client.get(
         reverse('tardis.apps.related_info.views.' +
                 'get_or_update_or_delete_related_info',
                 args=[self.experiment.id, obj['id']]))
     expect(response.status_code).to_equal(200)
Esempio n. 6
0
    def setUp(self):
        # Load schemas for test
        from django.core.management import call_command

        call_command("loaddata", "as_schemas")
        self.experiment = None
        Location.force_initialize()

        try:
            self.user = User.objects.get(username="******")
        except User.DoesNotExist:
            self.user = User.objects.create_user("test", "", "test")
            self.user.save()

        self.userprofile = UserProfile(user=self.user).save()

        filename = path.join(path.abspath(path.dirname(__file__)), "./METS_test.xml")

        expid, sync_path = _registerExperimentDocument(filename, self.user, expid=None)
        ensure(
            sync_path.startswith(settings.SYNC_TEMP_PATH),
            True,
            "Sync path should be influenced by SYNC_TEMP_PATH: %s" % sync_path,
        )
        self.experiment = Experiment.objects.get(pk=expid)
        self.sync_path = sync_path
Esempio n. 7
0
    def test_ensures_suitable_license(self):
        suitableCombinations = (
            (Experiment.PUBLIC_ACCESS_NONE, ''),
            (Experiment.PUBLIC_ACCESS_METADATA, ''),
            (Experiment.PUBLIC_ACCESS_NONE, self.restrictiveLicense.id),
            (Experiment.PUBLIC_ACCESS_METADATA, self.restrictiveLicense.id),
            (Experiment.PUBLIC_ACCESS_FULL, self.permissiveLicense.id),
        )
        unsuitableCombinations = (
            (Experiment.PUBLIC_ACCESS_NONE, self.permissiveLicense.id),
            (Experiment.PUBLIC_ACCESS_METADATA, self.permissiveLicense.id),
            (Experiment.PUBLIC_ACCESS_METADATA, self.inactiveLicense.id),
            (Experiment.PUBLIC_ACCESS_FULL, self.inactiveLicense.id),
            (Experiment.PUBLIC_ACCESS_FULL, ''),
            (Experiment.PUBLIC_ACCESS_FULL, self.restrictiveLicense.id),
        )

        # Check we accept valid input
        for public_access, license_id in suitableCombinations:
            print "Suitable combination: %d %s" % (public_access, license_id)
            data = {'public_access': str(public_access), 'license': license_id}
            form = RightsForm(data)
            ensure(form.is_valid(), True, form.errors)

        # Check we reject invalid input
        for public_access, license_id in unsuitableCombinations:
            print "Unsuitable combination: %d %s" % (public_access, license_id)
            data = {'public_access': str(public_access), 'license': license_id}
            form = RightsForm(data)
            ensure(form.is_valid(), False)
Esempio n. 8
0
    def test_login(self):
        from django.contrib.auth.models import User
        user = '******'
        pwd = 'test'
        email = ''
        User.objects.create_user(user, email, pwd)

        ensure(self.client.login(username=user, password=pwd), True)
Esempio n. 9
0
 def testForbiddenWithoutLogin(self):
     client = Client()
     response = client.get(self._get_staging_url())
     # Expect a redirect to login
     expect(response.status_code).to_equal(302)
     login_url = reverse('tardis.tardis_portal.views.login')
     ensure(login_url in response['Location'], True,
            "Redirect URL was not to login.")
Esempio n. 10
0
    def test_login(self):
        from django.contrib.auth.models import User
        user = '******'
        pwd = 'test'
        email = ''
        User.objects.create_user(user, email, pwd)

        ensure(self.client.login(username=user, password=pwd), True)
Esempio n. 11
0
 def testInfoHasEtags(self):
     client = Client()
     for format_ in ("json", "xml"):
         kwargs = {"datafile_id": self.datafile.id, "format": format_}
         url = reverse("tardis.tardis_portal.iiif.download_info", kwargs=kwargs)
         response = client.get(url)
         expect(response.status_code).to_equal(200)
         # Check etag exists
         ensure("Etag" in response, True, "Info should have an etag")
Esempio n. 12
0
 def check_item(item):
     ensure("id" in item, True, "Missing dataset ID")
     dataset = datasets[item["id"]]
     # Check attributes
     expect(item["description"]).to_equal(dataset.description)
     expect(item["immutable"]).to_equal(dataset.immutable)
     # todo - put ye test back
     # Check experiment list is the same
     expect(frozenset(item["experiments"])).to_equal(frozenset(dataset.experiments.values_list("id", flat=True)))
Esempio n. 13
0
    def test_urls_with_some_content(self):
        # Things that might tend to be in a real live system
        user = '******'
        pwd = User.objects.make_random_password()
        user = User.objects.create(username=user,
                                   email='*****@*****.**',
                                   first_name="Test",
                                   last_name="User")
        user.set_password(pwd)
        user.save()
        UserProfile(user=user).save()
        experiment = Experiment.objects.create(title="Test Experiment",
                                               created_by=user,
                                               public_access= \
                                                 Experiment.PUBLIC_ACCESS_FULL)
        experiment.save()
        acl = ObjectACL(pluginId=django_user,
                        entityId=str(user.id),
                        content_object=experiment,
                        canRead=True,
                        canWrite=True,
                        canDelete=True,
                        isOwner=True)
        acl.save()
        dataset = Dataset(description="test dataset")
        dataset.save()
        dataset.experiments.add(experiment)
        dataset.save()

        # Test everything works
        c = Client()
        c.login(username=user, password=pwd)
        urls = ['/about/', '/stats/']
        urls += [
            '/experiment/list/%s' % part
            for part in ('mine', 'shared', 'public')
        ]
        urls += [ '/experiment/%s/' % part \
                    for part in ('register', 'search') ]
        urls += ['/experiment/view/%d/' % experiment.id]
        urls += [ '/ajax/experiment/%d/%s' % (experiment.id, tabpane) \
                    for tabpane in ('description', 'datasets', 'rights') ]
        urls += ['/ajax/datafile_list/%d/' % dataset.id]
        urls += ['/ajax/dataset_metadata/%d/' % dataset.id]

        for u in urls:
            response = c.get(u)
            ensure(response.status_code, 200,
                   "%s should have returned 200 but returned %d"\
                   % (u, response.status_code))

        redirect_urls = ['/experiment/list', '/experiment/view/']

        for u in redirect_urls:
            response = c.get(u)
            expect(response.status_code).to_equal(302)
Esempio n. 14
0
 def testInfoHasEtags(self):
     client = Client()
     for format_ in ('json', 'xml'):
         kwargs = {'datafile_id': self.datafile.id, 'format': format_}
         url = reverse('tardis.tardis_portal.iiif.download_info',
                       kwargs=kwargs)
         response = client.get(url)
         expect(response.status_code).to_equal(200)
         # Check etag exists
         ensure('Etag' in response, True, "Info should have an etag")
Esempio n. 15
0
def _check_compliance_level(response):
    """
    Current complies with Level 1 API, so should assert no more.
    """
    import re
    ensure(re.search(r'\<http:\/\/library.stanford.edu\/iiif\/image-api\/'+\
                     r'compliance.html#level[01]\>;rel="compliesTo"',
                     response['Link']) != None,
           True,
           "Compliance header missing")
Esempio n. 16
0
def step_impl(context, address_name):
    new_address_alias = context.MyAddress.update_address(address_name)
    if new_address_alias is not None:
        #Asserting update is complete
        ensure(
            context.MyAddress.is_address_existed(new_address_alias) == True,
            True)
        ensure(
            context.MyAddress.is_address_existed(address_name) == False, True,
            "Fail to update address %s" % address_name)
Esempio n. 17
0
def _check_compliance_level(response):
    """
    Current complies with Level 1 API, so should assert no more.
    """
    import re
    ensure(re.search(r'\<http:\/\/library.stanford.edu\/iiif\/image-api\/'+\
                     r'compliance.html#level[01]\>;rel="compliesTo"',
                     response['Link']) != None,
           True,
           "Compliance header missing")
Esempio n. 18
0
 def check_item(item):
     ensure('id' in item, True, "Missing dataset ID")
     dataset = datasets[item['id']]
     # Check attributes
     expect(item['description']).to_equal(dataset.description)
     expect(item['immutable']).to_equal(dataset.immutable)
     # todo - put ye test back
     # Check experiment list is the same
     expect(frozenset(item['experiments']))\
         .to_equal(frozenset(dataset.experiments\
                                 .values_list('id', flat=True)))
Esempio n. 19
0
 def check_item(item):
     ensure('id' in item, True, "Missing dataset ID")
     dataset = datasets[item['id']]
     # Check attributes
     expect(item['description']).to_equal(dataset.description)
     expect(item['immutable']).to_equal(dataset.immutable)
     # todo - put ye test back
     # Check experiment list is the same
     expect(frozenset(item['experiments']))\
         .to_equal(frozenset(dataset.experiments\
                                 .values_list('id', flat=True)))
Esempio n. 20
0
 def testInfoHasEtags(self):
     client = Client()
     for format_ in ('json', 'xml'):
         kwargs = {'datafile_id': self.datafile.id,
                   'format': format_ }
         url = reverse('tardis.tardis_portal.iiif.download_info',
                       kwargs=kwargs)
         response = client.get(url)
         expect(response.status_code).to_equal(200)
         # Check etag exists
         ensure('Etag' in response, True, "Info should have an etag")
Esempio n. 21
0
    def test_urls_with_some_content(self):
        # Things that might tend to be in a real live system
        user = '******'
        pwd = User.objects.make_random_password()
        user = User.objects.create(username=user, email='*****@*****.**',
                                   first_name="Test", last_name="User")
        user.set_password(pwd)
        user.save()
        UserProfile(user=user).save()
        experiment = Experiment.objects.create(title="Test Experiment",
                                               created_by=user,
                                               public_access= \
                                                 Experiment.PUBLIC_ACCESS_FULL)
        experiment.save()
        acl = ExperimentACL(pluginId=django_user,
                            entityId=str(user.id),
                            experiment=experiment,
                            canRead=True,
                            canWrite=True,
                            canDelete=True,
                            isOwner=True)
        acl.save()
        dataset = Dataset(description="test dataset")
        dataset.save()
        dataset.experiments.add(experiment)
        dataset.save()


        # Test everything works
        c = Client()
        c.login(username=user, password=pwd)
        urls = [ '/about/', '/stats/']
        urls += [ '/experiment/list/%s' % part
                    for part in ('mine', 'shared', 'public')]
        urls += [ '/experiment/%s/' % part \
                    for part in ('register', 'search') ]
        urls += [ '/experiment/view/%d/' % experiment.id ]
        urls += [ '/ajax/experiment/%d/%s' % (experiment.id, tabpane) \
                    for tabpane in ('description', 'datasets', 'rights') ]
        urls += [ '/ajax/datafile_list/%d/' % dataset.id ]
        urls += [ '/ajax/dataset_metadata/%d/' % dataset.id ]

        for u in urls:
            response = c.get(u)
            ensure(response.status_code, 200,
                   "%s should have returned 200 but returned %d"\
                   % (u, response.status_code))

        redirect_urls = [ '/experiment/list', '/experiment/view/' ]

        for u in redirect_urls:
            response = c.get(u)
            expect(response.status_code).to_equal(302)
Esempio n. 22
0
 def testImageHasEtags(self):
     client = Client()
     kwargs = {'datafile_id': self.datafile.id,
               'region': 'full',
               'size': 'full',
               'rotation': '0',
               'quality': 'native' }
     url = reverse('tardis.tardis_portal.iiif.download_image', kwargs=kwargs)
     response = client.get(url)
     expect(response.status_code).to_equal(200)
     # Check etag exists
     ensure('Etag' in response, True, "Image should have an etag")
Esempio n. 23
0
    def test_search_urls(self):
        # Load schemas for test
        from django.core.management import call_command
        call_command('loaddata', 'as_schemas')

        c = Client()
        urls = ('/datafile/search/?type=' + x for x in ['mx', 'ir', 'saxs'])

        for u in urls:
            response = c.get(u)
            print str(response)
            ensure(response.status_code, 200)
Esempio n. 24
0
    def test_search_urls(self):
        # Load schemas for test
        from django.core.management import call_command
        call_command('loaddata', 'as_schemas')

        c = Client()
        urls = ('/datafile/search/?type='+x for x in ['mx', 'ir', 'saxs'])

        for u in urls:
            response = c.get(u)
            print str(response)
            ensure(response.status_code, 200)
Esempio n. 25
0
    def test_search_urls(self):
        # Load schemas for test
        from django.core.management import call_command

        call_command("loaddata", "as_schemas")

        c = Client()
        urls = ("/datafile/search/?type=" + x for x in ["mx", "ir", "saxs"])

        for u in urls:
            response = c.get(u)
            print str(response)
            ensure(response.status_code, 200)
def step_impl(context, info, column):
    """Check whether the given info does not appear in the given column."""
    found = False
    WebDriverWait(context.driver, WAIT_SECONDS).until(
        expected_conditions.visibility_of_element_located((By.CLASS_NAME,
                                                           column)))
    elements = context.driver.find_elements_by_class_name(column)
    for element in elements:
        if element.text == info:
            print(element.text)
            found = True
    error_msg = "I should not see '%s' in '%s'" % (info, column)
    ensure(found, False, error_msg)
Esempio n. 27
0
 def testImageHasEtags(self):
     client = Client()
     kwargs = {
         "datafile_id": self.datafile.id,
         "region": "full",
         "size": "full",
         "rotation": "0",
         "quality": "native",
     }
     url = reverse("tardis.tardis_portal.iiif.download_image", kwargs=kwargs)
     response = client.get(url)
     expect(response.status_code).to_equal(200)
     # Check etag exists
     ensure("Etag" in response, True, "Image should have an etag")
Esempio n. 28
0
 def testImageHasEtags(self):
     client = Client()
     kwargs = {
         'datafile_id': self.datafile.id,
         'region': 'full',
         'size': 'full',
         'rotation': '0',
         'quality': 'native'
     }
     url = reverse('tardis.tardis_portal.iiif.download_image',
                   kwargs=kwargs)
     response = client.get(url)
     expect(response.status_code).to_equal(200)
     # Check etag exists
     ensure('Etag' in response, True, "Image should have an etag")
Esempio n. 29
0
    def setUp(self):
        # Load schemas for test
        from django.core.management import call_command
        call_command('loaddata', 'as_schemas')
        self.experiment = None

        try:
            self.user = User.objects.get(username='******')
        except User.DoesNotExist:
            self.user = User.objects.create_user('test', '', 'test')
            self.user.save()

        filename = path.join(path.abspath(path.dirname(__file__)),
                             './METS_test.xml')

        expid, sync_path = _registerExperimentDocument(filename,
                                                       self.user,
                                                       expid=None)
        ensure(sync_path.startswith(settings.SYNC_TEMP_PATH), True,
               "Sync path should be influenced by SYNC_TEMP_PATH: %s" %
               sync_path)
        self.experiment = Experiment.objects.get(pk=expid)
        self.sync_path = sync_path
Esempio n. 30
0
 def testCanCreate(self):
     params = {'type': 'website',
               'identifier': 'https://www.google.com/',
               'title': 'Google',
               'notes': 'This is a note.'}
     response = self.client.post(
         reverse('tardis.apps.related_info.views.'
                 + 'list_or_create_related_info',
                 args=[self.experiment.id]),
         data=json.dumps(params),
         content_type='application/json')
     # Check that content reports as created, returns the created object
     expect(response.status_code).to_equal(201)
     obj = json.loads(response.content)
     ensure(isinstance(obj['id'], int), True,
            message='Created object should have an ID.')
     for k, v in params.items():
         expect(obj[k]).to_equal(v)
     # Check that creation really did persist
     response = self.client.get(
         reverse('tardis.apps.related_info.views.'
                 + 'get_or_update_or_delete_related_info',
                 args=[self.experiment.id, obj['id']]))
     expect(response.status_code).to_equal(200)
def step_impl(context, value):
    element = context.driver.find_element_by_id('search_results')
    #expect(element.text).to_contain(value)
    error_msg = "I should not see '%s' in '%s'" % (value, element.text)
    ensure(value in element.text, False, error_msg)
Esempio n. 32
0
def step_impl(context, num, product_id):
    element = context.driver.find_element_by_id("search_results")
    rows = element.find_elements_by_xpath("//table/tbody/tr/td[2]")
    matching = [row for row in rows if (int(row.text) == int(product_id))]
    error_msg = "Unexpected number of rows"
    ensure(len(matching), int(num), error_msg)
Esempio n. 33
0
def step_impl(context, message):
    error_msg = 'I should not see "%s" in "%s"' % (message,
                                                   context.driver.title)
    ensure(message in context.driver.title, False, error_msg)
Esempio n. 34
0
def step_impl(context, message):
    error_msg = "I should not see '{}' in '{}'".format(message, context.resp.text)
    ensure(message in context.resp.text, False, error_msg)
Esempio n. 35
0
 def test_root(self):
     ensure(Client().get('/').status_code, 200)
Esempio n. 36
0
    def testImageCacheControl(self):
        client = Client()
        kwargs = {
            "datafile_id": self.datafile.id,
            "region": "full",
            "size": "full",
            "rotation": "0",
            "quality": "native",
        }
        url = reverse("tardis.tardis_portal.iiif.download_image", kwargs=kwargs)
        response = client.get(url)
        expect(response.status_code).to_equal(200)
        # Check etag exists
        ensure("Cache-Control" in response, True, "Image should have a Cache-Control header")
        ensure("max-age" in response["Cache-Control"], True, "Image should have a Cache-Control header")
        # By default the image is public, so
        ensure("public" in response["Cache-Control"], True, "Image should have a Cache-Control header")

        is_logged_in = client.login(username="******", password="******")
        expect(is_logged_in).to_be_truthy()

        experiment = self.datafile.dataset.get_first_experiment()
        experiment.public_access = Experiment.PUBLIC_ACCESS_NONE
        experiment.save()

        url = reverse("tardis.tardis_portal.iiif.download_image", kwargs=kwargs)
        response = client.get(url)
        expect(response.status_code).to_equal(200)
        # Check etag exists
        ensure("Cache-Control" in response, True, "Image should have a Cache-Control header")
        ensure("max-age" in response["Cache-Control"], True, "Image should have a Cache-Control header")
        # By default the image is now private, so
        ensure("private" in response["Cache-Control"], True, "Image should have a Cache-Control header")
Esempio n. 37
0
def step_impl(context, name, available):
    element = context.driver.find_element_by_id('search_results')
    error_msg = "I should not see '%s' in '%s' with availability set to '%s'" % (name, element.text, available)
    ensure((name in element.text and available in element.text), False, error_msg)
Esempio n. 38
0
def step_impl(context, text_string, element_name):
    element_id = 'inventory_' + element_name.lower()
    element = context.driver.find_element_by_id(element_id)
    error_msg = "I should not see '%s' in '%s'" % (text_string, element_name)
    ensure(text_string in element_name, False, error_msg)
Esempio n. 39
0
    def testImageCacheControl(self):
        client = Client()
        kwargs = {'datafile_id': self.datafile.id,
                  'region': 'full',
                  'size': 'full',
                  'rotation': '0',
                  'quality': 'native' }
        url = reverse('tardis.tardis_portal.iiif.download_image', kwargs=kwargs)
        response = client.get(url)
        expect(response.status_code).to_equal(200)
        # Check etag exists
        ensure('Cache-Control' in response, True,
               "Image should have a Cache-Control header")
        ensure('max-age' in response['Cache-Control'], True,
               "Image should have a Cache-Control header")
        # By default the image is public, so
        ensure('public' in response['Cache-Control'], True,
               "Image should have a Cache-Control header")

        is_logged_in = client.login(username='******', password='******')
        expect(is_logged_in).to_be_truthy()

        experiment = self.datafile.dataset.get_first_experiment()
        experiment.public_access = Experiment.PUBLIC_ACCESS_NONE
        experiment.save()

        url = reverse('tardis.tardis_portal.iiif.download_image', kwargs=kwargs)
        response = client.get(url)
        expect(response.status_code).to_equal(200)
        # Check etag exists
        ensure('Cache-Control' in response, True,
               "Image should have a Cache-Control header")
        ensure('max-age' in response['Cache-Control'], True,
               "Image should have a Cache-Control header")
        # By default the image is now private, so
        ensure('private' in response['Cache-Control'], True,
               "Image should have a Cache-Control header")
Esempio n. 40
0
def step_impl(context, num):
    element = context.driver.find_element_by_id("search_results")
    rows = element.find_elements_by_xpath("//table/tbody/tr")
    error_msg = "Unexpected number of rows"
    ensure(len(rows), int(num), error_msg)
Esempio n. 41
0
def step_impl(context, address_name):
    if context.MyAddress.delete_address(address_name) is True:
        #Asserting delete is completes
        ensure(
            context.MyAddress.is_address_existed(address_name) == False, True,
            "Fail to delete address %s" % address_name)
def step_impl(context, name):
    """ Check item not in the result """
    element = context.driver.find_element_by_id("search_results")
    error_msg = "I should not see '%s' in '%s'" % (name, element.text)
    ensure(name in element.text, False, error_msg)
Esempio n. 43
0
    def testImageCacheControl(self):
        client = Client()
        kwargs = {
            'datafile_id': self.datafile.id,
            'region': 'full',
            'size': 'full',
            'rotation': '0',
            'quality': 'native'
        }
        url = reverse('tardis.tardis_portal.iiif.download_image',
                      kwargs=kwargs)
        response = client.get(url)
        expect(response.status_code).to_equal(200)
        # Check etag exists
        ensure('Cache-Control' in response, True,
               "Image should have a Cache-Control header")
        ensure('max-age' in response['Cache-Control'], True,
               "Image should have a Cache-Control header")
        # By default the image is public, so
        ensure('public' in response['Cache-Control'], True,
               "Image should have a Cache-Control header")

        is_logged_in = client.login(username='******', password='******')
        expect(is_logged_in).to_be_truthy()

        experiment = self.datafile.dataset.get_first_experiment()
        experiment.public_access = Experiment.PUBLIC_ACCESS_NONE
        experiment.save()

        url = reverse('tardis.tardis_portal.iiif.download_image',
                      kwargs=kwargs)
        response = client.get(url)
        expect(response.status_code).to_equal(200)
        # Check etag exists
        ensure('Cache-Control' in response, True,
               "Image should have a Cache-Control header")
        ensure('max-age' in response['Cache-Control'], True,
               "Image should have a Cache-Control header")
        # By default the image is now private, so
        ensure('private' in response['Cache-Control'], True,
               "Image should have a Cache-Control header")
Esempio n. 44
0
def step_impl(context, id):
    element = context.driver.find_element_by_id('results')
    error_msg = "I should not see '%s' in '%s'" % (id, element.text)
    ensure(id in element.text, False, error_msg)
Esempio n. 45
0
 def test_root(self):
     ensure(Client().get('/').status_code, 200)
def step_impl(context, message):
    """ Check message not on the UI """
    error_message = u'I should not see {message} in {context.resp.text}'
    ensure(message in context.resp.text, False, error_message)
def step_impl(context, name):
    element = context.driver.find_element_by_id('search_results')
    error_msg = "I should not see '%s' in '%s'" % (name, element.text)
    ensure(name in element.text, False, error_msg)
def step_impl(context, message):
    error_msg = "I should not see '%s' in '%s'" % (message, context.resp.text)
    ensure(message in context.resp.text, False, error_msg)
Esempio n. 49
0
def step_impl(context, message):
    # assert message not in str(context.resp.data)
    error_msg = "I should not see '%s' in '%s'" % (message, context.resp.text)
    ensure(message in context.resp.text, False, error_msg)