def _makeRecurrenceRuleSet(self, until=None, freq='daily'):
     ruleItem = RecurrenceRule(None, itsParent=self.sandbox)
     ruleItem.freq = freq
     if until is not None:
         ruleItem.until = until
     ruleSetItem = RecurrenceRuleSet(None, itsParent=self.sandbox)
     ruleSetItem.addRule(ruleItem)
     return ruleSetItem
Exemplo n.º 2
0
 def _makeRecurrenceRuleSet(self, until=None, freq='daily'):
     ruleItem = RecurrenceRule(None, itsParent=self.sandbox)
     ruleItem.freq = freq
     if until is not None:
         ruleItem.until = until
     ruleSetItem = RecurrenceRuleSet(None, itsParent=self.sandbox)
     ruleSetItem.addRule(ruleItem)
     return ruleSetItem
Exemplo n.º 3
0
 def _createBasicItem(self, freq):
     ruleItem = RecurrenceRule(None, view=self.rep.view)
     ruleItem.until = getattr(self, freq)['end']
     if freq == 'weekly':
         self.assertEqual(ruleItem.freq, 'weekly',
                          "freq should default to weekly")
     else:
         ruleItem.freq = freq
     return ruleItem
Exemplo n.º 4
0
 def _createBasicItem(self, freq):
     ruleItem = RecurrenceRule(None, itsView=self.view)
     ruleItem.until = getattr(self, freq)['end']
     if freq == 'weekly':
         self.assertEqual(ruleItem.freq, 'weekly', 
                          "freq should default to weekly")
     else:
         ruleItem.freq = freq
     return ruleItem
Exemplo n.º 5
0
 def _makeRecurrenceRuleSet(self, until=None, freq='daily', byweekday=None):
     ruleItem = RecurrenceRule(None, itsView=self.view)
     ruleItem.freq = freq
     if byweekday is not None:
         ruleItem.byweekday = byweekday
     if until is not None:
         ruleItem.until = until
     ruleSetItem = RecurrenceRuleSet(None, itsView=self.view)
     ruleSetItem.addRule(ruleItem)
     return ruleSetItem
Exemplo n.º 6
0
 def _makeRecurrenceRuleSet(self, until=None, freq='daily', byweekday=None):
     ruleItem = RecurrenceRule(None, itsView=self.view)
     ruleItem.freq = freq
     if byweekday is not None:
         ruleItem.byweekday = byweekday
     if until is not None:
         ruleItem.until = until
     ruleSetItem = RecurrenceRuleSet(None, itsView=self.view)
     ruleSetItem.addRule(ruleItem)
     return ruleSetItem
Exemplo n.º 7
0
 def _createRuleSetItem(self, freq):
     ruleItem = RecurrenceRule(None, view=self.rep.view)
     ruleItem.until = getattr(self, freq)['end']
     ruleItem.untilIsDate = False
     if freq == 'weekly':
         self.assertEqual(ruleItem.freq, 'weekly', 
                          "freq should default to weekly")
     else:
         ruleItem.freq = freq
     ruleSetItem = RecurrenceRuleSet(None, view=self.rep.view)
     ruleSetItem.addRule(ruleItem)
     return ruleSetItem
Exemplo n.º 8
0
 def _createRuleSetItem(self, freq):
     ruleItem = RecurrenceRule(None, view=self.rep.view)
     ruleItem.until = getattr(self, freq)['end']
     ruleItem.untilIsDate = False
     if freq == 'weekly':
         self.assertEqual(ruleItem.freq, 'weekly',
                          "freq should default to weekly")
     else:
         ruleItem.freq = freq
     ruleSetItem = RecurrenceRuleSet(None, view=self.rep.view)
     ruleSetItem.addRule(ruleItem)
     return ruleSetItem
Exemplo n.º 9
0
def addEventStamp(item, recur=False):
    es = EventStamp(item)
    es.add()
    es.summary = uw("Test Event Summary")

    tzinfo = item.itsView.tzinfo.floating

    # Choose random days, hours
    startDelta = timedelta(days=random.randint(0, 30),
                           hours=random.randint(0, 24))

    now = datetime.now(tzinfo)

    closeToNow = datetime(now.year,
                          now.month,
                          now.day,
                          now.hour,
                          int(now.minute / 30) * 30,
                          tzinfo=now.tzinfo)

    es.startTime = closeToNow + startDelta
    es.anyTime = True

    # Choose random minutes
    es.duration = timedelta(minutes=60)

    es.location = Calendar.Location.getLocation(view, uw("My House"))

    es.itsItem.importance = random.choice(pim.ImportanceEnum.values)

    es.itsItem.setTriageStatus(randomEnum(pim.TriageEnum))

    if recur:
        rule = RecurrenceRule(itsView=view)
        rule.freq = 'daily'
        rule.until = datetime(2008, 9, 14, 19, tzinfo=view.tzinfo.default)
        rule.untilIsDate = False

        ruleSet = RecurrenceRuleSet(itsView=view)
        ruleSet.addRule(rule)

        es.rruleset = ruleSet

    return es
Exemplo n.º 10
0
def addEventStamp(item, recur=False):
    es = EventStamp(item)
    es.add()
    es.summary = uw("Test Event Summary")

    tzinfo = view.tzinfo.floating

    # Choose random days, hours
    startDelta = timedelta(days=random.randint(0, 30),
                           hours=random.randint(0, 24))

    now = datetime.now(tzinfo)

    closeToNow = datetime(now.year, now.month, now.day, now.hour,
                          int(now.minute/30) * 30, tzinfo=now.tzinfo)

    es.startTime = closeToNow + startDelta
    es.anyTime = True

    # Choose random minutes
    es.duration = timedelta(minutes=60)

    es.location = Calendar.Location.getLocation(view, uw("My House"))

    es.itsItem.importance = random.choice(pim.ImportanceEnum.values)

    es.itsItem.setTriageStatus(randomEnum(pim.TriageEnum))

    if recur:
        rule = RecurrenceRule(itsView=view)
        rule.freq = 'daily'
        rule.until =  datetime(2008, 9, 14, 19, tzinfo=view.tzinfo.default)
        rule.untilIsDate = False

        ruleSet = RecurrenceRuleSet(itsView=view)
        ruleSet.addRule(rule)

        es.rruleset = ruleSet

    return es
Exemplo n.º 11
0
def createItems(paramDict):

    if bool(wx.GetApp()):
        view = QAUITestAppLib.App_ns.itsView
    else:  # when running unit tests there is no app
        view = NullRepositoryView(verify=True)
    tzinfo = view.tzinfo.getDefault()

    totalItems = int(paramDict['textCtrlTotalItems'])

    #get titles to use
    TITLES = getDataFromFile(paramDict['textCtrlTitleSourceFile'])

    #create collections to use
    collectionNames = addRandomWithoutDups(
        getDataFromFile(paramDict['textCtrlCollectionFileName']),
        int(paramDict['textCtrlCollectionCount']))
    sidebarCollections = createCollections(collectionNames, view)

    #determine how many collections each item should participate in
    collectionMembershipIndex = createMembershipIndex(
        paramDict['textCtrlCollectionMembership'], range(totalItems))
    collectionMembershipDict = {}
    ##fill collectionMembershipDict with correct number of collections for each item index
    for i in range(totalItems):
        collectionMembershipDict[i] = addRandomWithoutDups(
            sidebarCollections, collectionMembershipIndex[i])

    #get locations to use
    LOCATIONS = getDataFromFile(paramDict['textCtrlLocationSourceFilePath'])

    #get note field text
    NOTES = getDataFromFile(paramDict['textCtrlNoteSourceFilePath'], note=True)

    itemTypes = percentsToCount(
        totalItems, {
            'mail': int(paramDict['choicePercentMail']),
            'task': int(paramDict['choicePercentTask']),
            'event': int(paramDict['choicePercentEvent'])
        })

    triageStatus = percentsToCount(
        totalItems, {
            'unassigned': int(paramDict['choicePercentUnassignedStatus']),
            'now': int(paramDict['choicePercentNow']),
            'later': int(paramDict['choicePercentLater']),
            'done': int(paramDict['choicePercentDone'])
        },
        randomize=True)
    triageStatusAssignments = percentsToAssignments(triageStatus)
    #convert the string triage value to the triageEnum that can be used to set it
    triageEnums = {
        'now': pim.TriageEnum.now,
        'later': pim.TriageEnum.later,
        'done': pim.TriageEnum.done
    }
    triageStatusUnassigned = []
    for index, status in triageStatusAssignments.iteritems():
        if status == 'unassigned':
            triageStatusUnassigned.append(index)
        else:
            triageStatusAssignments[index] = triageEnums[status]

    recurTypes = percentsToCount(
        itemTypes['event'], {
            'non': int(paramDict['choicePercentNonRecurring']),
            'daily': int(paramDict['choicePercentDaily']),
            'weekly': int(paramDict['choicePercentWeekly']),
            'biweekly': int(paramDict['choicePercentBiWeekly']),
            'monthly': int(paramDict['choicePercentMonthly']),
            'yearly': int(paramDict['choicePercentYearly'])
        },
        randomize=True)

    durationTypes = percentsToCount(
        itemTypes['event'], {
            'allDay': int(paramDict['choicePercentAllDay']),
            'atTime': int(paramDict['choicePercentAtTime']),
            'anyTime': int(paramDict['choicePercentAnyTime']),
            'duration': int(paramDict['choicePercentDuration'])
        },
        randomize=True)

    eventStatus = percentsToCount(
        durationTypes['duration'], {
            'confirmed': int(paramDict['choicePercentConfirmed']),
            'FYI': int(paramDict['choicePercentFYI']),
            'tentative': int(paramDict['choicePercentTentative'])
        },
        randomize=True)
    eventStatusAssignment = percentsToAssignments(eventStatus)

    global startTimes
    startTimes = createStartTimeRange(paramDict['textCtrlTimeOfDay'],
                                      itemTypes['event'])

    startDateText = paramDict['textCtrlStartDate']
    if startDateText:
        y, m, d = startDateText.split(',')
        startDate = datetime(int(y), int(m), int(d))
        y, m, d = paramDict['textCtrlEndDate'].split(',')
        endDate = datetime(int(y), int(m), int(d))
        global dates
        dates = createDateRange(startDate, endDate)

    durationsTimed = createDurationIndex(paramDict['textCtrlDuration'],
                                         durationTypes['duration'])
    itemsWithDuration = durationsTimed.keys()

    relativeReminders, absoluteReminders = createAlarmIndex(
        paramDict['textCtrlAlarmSpec'], itemTypes['event'], totalItems, tzinfo)

    allRecurring = recurTypes['daily'] + recurTypes['weekly'] + recurTypes[
        'biweekly'] + recurTypes['monthly'] + recurTypes['yearly']
    recurenceEndDate = createEndDateIndex(
        paramDict['textCtrlRecurrenceEndDates'], allRecurring)

    # email stuff
    emailAddresses = []
    for firstName in firstNames:
        for lastName in lastNames:
            for domain in domainList:
                emailAddresses.append(firstName + lastName + '@' + domain)
    # get address sources
    if paramDict['textCtrlToFile'] == '':
        toAddresses = emailAddresses
    else:
        toAddresses = getDataFromFile(paramDict['textCtrlToFile'])

    if paramDict['textCtrlCCFileName'] == '':
        ccAddresses = emailAddresses
    else:
        ccAddresses = getDataFromFile(paramDict['textCtrlCCFileName'])

    if paramDict['textCtrlBCCFileName'] == '':
        bccAddresses = emailAddresses
    else:
        bccAddresses = getDataFromFile(paramDict['textCtrlBCCFileName'])

    # make email indexes from specs
    toIndex = createAddressIndex(itemTypes['mail'],
                                 paramDict['textCtrlToSpec'], toAddresses)
    ccIndex = createAddressIndex(itemTypes['mail'],
                                 paramDict['textCtrlCCSpec'], ccAddresses)
    bccIndex = createAddressIndex(itemTypes['mail'],
                                  paramDict['textCtrlBCCSpec'], bccAddresses)

    created = []
    for i in range(totalItems):
        created.append(pim.notes.Note(itsView=view))
        item = created[i]
        item.displayName = random.choice(TITLES)
        item.body = random.choice(NOTES)
        if i not in triageStatusUnassigned:
            item.setTriageStatus(triageStatusAssignments[i])
        if i in absoluteReminders.keys():
            item.setUserReminderTime(
                datetime.combine(date.today(), absoluteReminders[i]))
        if i in itemTypes['mail']:
            mailStampedItem = pim.MailStamp(item)
            mailStampedItem.add()
            if i in toIndex.keys():
                for address in toIndex[i]:
                    mailStampedItem.toAddress.append(
                        Mail.EmailAddress.getEmailAddress(view, address))
            if i in ccIndex.keys():
                for address in ccIndex[i]:
                    mailStampedItem.ccAddress.append(
                        Mail.EmailAddress.getEmailAddress(view, address))
            if i in bccIndex.keys():
                for address in bccIndex[i]:
                    mailStampedItem.bccAddress.append(
                        Mail.EmailAddress.getEmailAddress(view, address))
        if i in itemTypes['task']: pim.TaskStamp(item).add()
        if i in itemTypes['event']:
            eventStampedItem = pim.EventStamp(item)
            eventStampedItem.add()
            if i in itemsWithDuration:  #if its an event with duration then assign status
                eventStampedItem.transparency = eventStatusAssignment[i].lower(
                )
            eventStampedItem.location = Calendar.Location.getLocation(
                view, random.choice(LOCATIONS))
            eventStampedItem.anyTime = i in durationTypes['anyTime']
            eventStampedItem.allDay = i in durationTypes['allDay']
            eventStampedItem.startTime = createStartTime(i, tzinfo)
            if i in durationTypes['atTime']:
                eventStampedItem.duration = timedelta(0)
            else:
                if i in itemsWithDuration:
                    eventStampedItem.duration = durationsTimed[i]
            if i in relativeReminders.keys():
                eventStampedItem.setUserReminderInterval(relativeReminders[i])
            if i in allRecurring:
                ruleItem = RecurrenceRule(None, itsView=view)
                ruleSetItem = RecurrenceRuleSet(None, itsView=view)
                recurFreq = rangeName(i, recurTypes)
                #specail case biweekly
                if recurFreq == 'biweekly':
                    ruleItem.freq = 'weekly'
                    ruleItem.interval = 2
                else:
                    ruleItem.freq = recurFreq
                #add end date
                if i in recurenceEndDate and recurenceEndDate[
                        i]:  # zero means don't use an end date
                    endDateDate = calcEndDate(eventStampedItem.startTime,
                                              recurenceEndDate[i], recurFreq)
                    ruleItem.until = endDateDate
                ruleSetItem.addRule(ruleItem)
                eventStampedItem.rruleset = ruleSetItem
        for collection in collectionMembershipDict[i]:
            collection.add(item)
    return created  #return value used for testing in TestCreateItems.py:TestItemCreation
Exemplo n.º 12
0
def GenerateCalendarEvent(view, args):
    """ Generate one calendarEvent item """
    event = Calendar.CalendarEvent(itsView=view)

    # displayName
    if args[0]=='*': # semi-random data
        event.displayName = random.choice(HEADLINES)

    elif not args[0]=='':
        event.displayName = u"%s" %args[0]
    else:
        event.displayName = u'untitled'

    if TEST_I18N:
        event.displayName = uw(event.displayName)

    #startTime (startDate + startTime) + TimeZone
    event.startTime = ReturnCompleteDatetime(view, args[2], args[3],
                                             tz=args[12])
   
    #anyTime
    if args[4]=='*': # semi-random data
        r = random.randint(0,100)
        if r < 95: # 95% chance that we'll turn anyTime off
            event.anyTime = False
        else:
            event.anyTime = True
    elif args[4]=='TRUE' :
        event.anyTime = True
    else:
        event.anyTime = False

    #allDay    
    if args[5]=='*': # semi-random data
        r = random.randint(0,100)
        if r < 5: # 5% chance of allDay
            event.allDay = True
        else:
            event.allDay = False
    elif args[5]=='TRUE' :
        event.allDay = True
    else:
        event.allDay = False

    #duration
    if args[6]=='*': # semi-random data
        event.duration = timedelta(minutes=random.choice(DURATIONS))
    elif not args[6]=='':
        event.duration = timedelta(minutes=string.atoi(args[6]))
    else:
        event.duration = timedelta(minutes=60) #default value 1h

    #reminders
    if not args[7]=='':
        if args[7]=='*': # semi-random data
            reminderInterval = random.choice(REMINDERS)
        else:
            reminderInterval = string.atoi(args[7])
        event.userReminderInterval = timedelta(minutes=-reminderInterval)

    #location
    if args[8]=='*': # semi-random data
        event.location = Calendar.Location.getLocation(view, random.choice(LOCATIONS))

    elif not args[8]=='':
        event.location = Calendar.Location.getLocation(view,u"%s"%args[8])    

    if TEST_I18N:
        event.location = uw(event.location)

    #status (only 3 values allowed : 'Confirmed','Tentative','fyi')
    if args[9]=='*': # semi-random data
        event.transparency = random.choice(STATUS)
    elif string.lower(args[9]) in STATUS:    
        event.transparency = string.lower(args[9])
    else: # default value (normal)
        event.transparency = 'confirmed'
    
    #recurrence ('daily','weekly','monthly','yearly') + recurrence end date
    ruleItem = RecurrenceRule(None, itsView=view)
    ruleSetItem = RecurrenceRuleSet(None, itsView=view)
    if not args[11] == '':
        ruleItem.until = ReturnCompleteDatetime(view, args[11])
    if args[10]=='*': # semi-random data
        ruleItem.freq = random.choice(RECURRENCES)
        ruleSetItem.addRule(ruleItem)
        event.rruleset = ruleSetItem
    elif string.lower(args[10]) in RECURRENCES:
        ruleItem.freq = string.lower(args[10])
        ruleSetItem.addRule(ruleItem)
        event.rruleset = ruleSetItem

    #collection
    if args[1]=='*': # semi-random data
        if not len(collectionsDict) == 0:
            collectionsDict.values()[random.randint(0,len(collectionsDict)-1)].add(event)
    elif not args[1]=='':
        collectionNames = string.split(args[1], ';')
        for name in collectionNames:
            if collectionsDict.has_key(name):
                collectionsDict[name].add(event)
            else:
                GenerateCollection(view, [name])
                collectionsDict[name].add(event)

    return event