Пример #1
0
def step_impl(context, timestamp):
    parsed = et.fromstring(str(context.response.text))
    element = "jobref"
    jobreflist = parsed.findall(get_UwsName(element))
    for jobref in jobreflist:
        refId = jobref.get("id")
        link = jobref.get(get_XlinkName("href"))
        joblink = get_joblink(context.server, link, refId)
        # make a get request and compare the creationTime
        #raise NotImplementedError("joblink", joblink)
        context.joblink = joblink
        context.execute_steps(u'''
            When I make a GET request to URL "{url}"
            Then the response status should be "200"
            And the UWS job creationTime should be later than "{timestamp}"
            '''.format(url=joblink, timestamp=timestamp)
        )
Пример #2
0
def step_impl(context):
    parsed = et.fromstring(str(context.response.text))
    element = "jobref"
    jobreflist = parsed.findall(get_UwsName(element))
    timestamp = '2999-01-01T00:00:00'
    for jobref in jobreflist:
        refId = jobref.get("id")
        link = jobref.get(get_XlinkName("href"))
        joblink = get_joblink(context.server, link, refId)
        context.joblink = joblink;

        # make a get request and store the creationTime
        context.execute_steps(u'''
            When I make a GET request to URL "{url}"
            Then the UWS job creationTime should be earlier than or equal to "{timestamp}"
            '''.format(url=joblink, timestamp=timestamp)
        )
        timestamp = context.job.creationTime
Пример #3
0
def step_impl(context):
    parsed = et.fromstring(str(context.response.text))
    elementlist = parsed.findall(".//" + str(get_UwsName("jobref")))
    if len(elementlist) < 2:
        raise NotImplementedError("Job list contains only %d jobs. Cannot test using this step." % len(elementlist))
    # also cannot test this, if there are no creation times!!
    # Problem: there is not even any kind of ordering in the job list that I could assume,
    # so just search for the first two jobs that have a creationTime that is not exactly the same

    i = 0
    job_creationTimes = []
    while len(job_creationTimes) < 2:
        creationTime = None
        while creationTime is None and i < len(elementlist):
            jobref = elementlist[-i]  # use -i here, since I expect descending ordering, if any
            refId = jobref.get("id")
            link = jobref.get(get_XlinkName("href"))
            joblink = get_joblink(context.server, link, refId)
            response = requests.get(joblink, headers=context.headers, auth=context.auth)
            parsed = et.fromstring(str(response.text))
            creationTime = parsed.find(get_UwsName("creationTime")).text
            i = i + 1

        if creationTime is not None:
            # convert creationTime to UTC, in case it has a timezone attached:
            date = dateutil.parser.parse(creationTime)
            if date.utcoffset() is not None:
                utz = pytz.timezone("UTC")
                date = date.astimezone(utz).replace(tzinfo=None)
                date = date.isoformat()
            # check if it is not exactly the same as previous ones,
            # since we need different times for AFTER condition to work:
            if date not in job_creationTimes:
                job_creationTimes.append(date)
        else:
            raise NotImplementedError(
                "Cannot find enough jobs with a creationTime, thus cannot test Scenarios using this. %r %r"
                % (link, creationTime)
            )

    # store the smallest creationTime of these to ensure that I will get at
    # least one result returned when filtering by this creationTime
    context.creationTime_filter = min(job_creationTimes)