Пример #1
0
def test__build_tempate__hold_expires_in_a_long_time__expires_not_added_to_status_note(status, library, card):
    family = None

    hold = Hold(library, card)
    hold.status = (3, 5)
    hold.expires = datetime.date(2010, 7, 13)
    status.holds = [hold]

    template_values = libraryhippo.build_template([status], family)
    assert [] == template_values['holds_not_ready'][0].status_notes
Пример #2
0
def test__build_tempate__hold_expires_soon__expires_added_to_status_note(status, library, card):
    family = None

    hold = Hold(library, card)
    hold.status = (3, 5)
    hold.expires = datetime.date(2010, 2, 28)
    status.holds = [hold]

    template_values = libraryhippo.build_template([status], family)
    assert 'expires on 28 February (Sunday)' in template_values['holds_not_ready'][0].status_notes
Пример #3
0
def test__build_tempate__hold_expires_in_a_long_time__expires_not_added_to_status_note(
        status, library, card):
    family = None

    hold = Hold(library, card)
    hold.status = (3, 5)
    hold.expires = datetime.date(2010, 7, 13)
    status.holds = [hold]

    template_values = libraryhippo.build_template([status], family)
    assert [] == template_values['holds_not_ready'][0].status_notes
Пример #4
0
    def parse_holds(self, response):
        table_header = response.find("tr", attrs={"class": "patFuncHeaders"})
        if not table_header:
            return []
        headers = [th.string.strip() for th in table_header("th")]

        entries = []
        for row in table_header.findNextSiblings("tr"):
            entry = Hold(self.library, self.card)
            i = 0
            for cell in row.findAll(td_or_th_regex):
                column_name = headers[i]

                if column_name == "TITLE":
                    self.parse_title(cell, entry)
                elif column_name == "PICKUP LOCATION":
                    if cell.select:
                        all_selected = cell.select.findAll("option",
                                                           selected="selected")
                        if all_selected:
                            pickup = all_selected[0].string
                        else:
                            pickup = ""
                    else:
                        pickup = cell.string

                    # make sure we clean up the string
                    # also ensures that we're saving a true string,
                    # not a NaviagableString, which pickles terribly!
                    entry.pickup = str(pickup).strip()

                elif column_name == "STATUS":
                    entry.status = parse_hold_status(cell)

                elif column_name == "CANCEL IF NOT FILLED BY":
                    try:
                        entry.expires = parse_hold_expires(cell)
                    except:  # noqa E722 - do not use bare except
                        # expiration info isn't critical - ignore
                        pass

                elif column_name == "FREEZE":
                    try:
                        if parse_hold_frozen(cell):
                            entry.freeze()
                    except:  # noqa E722 - do not use bare except
                        # frozen info isn't critical - ignore
                        logging.warn("error getting frozen info",
                                     exc_info=True)
                        pass
                i += 1

            entries.append(entry)
        return entries
Пример #5
0
def test__build_tempate__hold_expires_soon__expires_added_to_status_note(
        status, library, card):
    family = None

    hold = Hold(library, card)
    hold.status = (3, 5)
    hold.expires = datetime.date(2010, 2, 28)
    status.holds = [hold]

    template_values = libraryhippo.build_template([status], family)
    assert 'expires on 28 February (Sunday)' in template_values[
        'holds_not_ready'][0].status_notes
Пример #6
0
    def parse_holds(self, response):
        table_header = response.find('tr', attrs={'class': 'patFuncHeaders'})
        if not table_header:
            return []
        headers = [th.string.strip() for th in table_header('th')]

        entries = []
        for row in table_header.findNextSiblings('tr'):
            entry = Hold(self.library, self.card)
            i = 0
            for cell in row('td'):
                column_name = headers[i]

                if column_name == 'TITLE':
                    self.parse_title(cell, entry)
                elif column_name == 'PICKUP LOCATION':
                    if cell.select:
                        pickup = cell.select.findAll('option', selected='selected')[0].string
                    else:
                        pickup = cell.string

                    # make sure we clean up the string
                    # also ensures that we're saving a true string,
                    # not a NaviagableString, which pickles terribly!
                    entry.pickup = str(pickup).strip()

                elif column_name == 'STATUS':
                    entry.status = parse_hold_status(cell)

                elif column_name == 'CANCEL IF NOT FILLED BY':
                    try:
                        entry.expires = parse_hold_expires(cell)
                    except:
                        # expiration info isn't critical - ignore
                        pass

                elif column_name == 'FREEZE':
                    try:
                        if parse_hold_frozen(cell):
                            entry.freeze()
                    except:
                        # frozen info isn't critical - ignore
                        logging.warn('error getting frozen info', exc_info=True)
                        pass
                i += 1

            entries.append(entry)
        return entries
Пример #7
0
    def parse_holds(self, response):
        table_header = response.find('tr', attrs={'class': 'patFuncHeaders'})
        if not table_header:
            return []
        headers = [th.string.strip() for th in table_header('th')]

        entries = []
        for row in table_header.findNextSiblings('tr'):
            entry = Hold(self.library, self.card)
            i = 0
            for cell in row('td'):
                column_name = headers[i]

                if column_name == 'TITLE':
                    self.parse_title(cell, entry)
                elif column_name == 'PICKUP LOCATION':
                    if cell.select:
                        pickup = cell.select.findAll('option', selected='selected')[0].string
                    else:
                        pickup = cell.string

                    # make sure we clean up the string
                    # also ensures that we're saving a true string,
                    # not a NaviagableString, which pickles terribly!
                    entry.pickup = str(pickup).strip()

                elif column_name == 'STATUS':
                    entry.status = parse_hold_status(cell)

                elif column_name == 'CANCEL IF NOT FILLED BY':
                    try:
                        entry.expires = parse_hold_expires(cell)
                    except: # noqa E722 - do not use bare except
                        # expiration info isn't critical - ignore
                        pass

                elif column_name == 'FREEZE':
                    try:
                        if parse_hold_frozen(cell):
                            entry.freeze()
                    except: # noqa E722 - do not use bare except
                        # frozen info isn't critical - ignore
                        logging.warn('error getting frozen info', exc_info=True)
                        pass
                i += 1

            entries.append(entry)
        return entries