def testLongDistanceDates(self):
        # If the result contains a year part, month part, week part
        # and day part the number of parts is controlled by
        # @max_no_sections (default 3)
        t1 = DateTime('2004/11/12 00:08:30.937 GMT')
        t2 = DateTime('2006/05/01 09:47:07.123 GMT')
        difference_default = Utils.timeSince(t1, t2)
        self.assertEqual(difference_default, '1 year and 5 months and 2 weeks')
        
        difference_2_parts = Utils.timeSince(t1, t2, max_no_sections=2)
        self.assertEqual(difference_2_parts, '1 year and 5 months')

        difference_99_parts = Utils.timeSince(t1, t2, max_no_sections=99)
        self.assertEqual(difference_99_parts, '1 year and 5 months and 2 weeks and 6 days')
Esempio n. 2
0
    def testLongDistanceDates(self):
        # If the result contains a year part, month part, week part
        # and day part the number of parts is controlled by
        # @max_no_sections (default 3)
        t1 = DateTime('2004/11/12 00:08:30.937 GMT')
        t2 = DateTime('2006/05/01 09:47:07.123 GMT')
        difference_default = Utils.timeSince(t1, t2)
        self.assertEqual(difference_default, '1 year and 5 months and 2 weeks')

        difference_2_parts = Utils.timeSince(t1, t2, max_no_sections=2)
        self.assertEqual(difference_2_parts, '1 year and 5 months')

        difference_99_parts = Utils.timeSince(t1, t2, max_no_sections=99)
        self.assertEqual(difference_99_parts,
                         '1 year and 5 months and 2 weeks and 6 days')
Esempio n. 3
0
 def testMinutes1(self):
     # the timeSince() function drops the hour
     # part if the difference is in days
     t1 = DateTime('2005/04/01 12:00')
     t2 = DateTime('2005/04/01 12:30')
     difference = Utils.timeSince(t1, t2)
     self.assertEqual(difference, 0)
 def testWeek1(self):
     # use the week notation
     t1 = DateTime('2005/04/01')
     t2 = DateTime('2005/04/08')
     difference = Utils.timeSince(t1, t2)
     
     self.assertEqual(difference, "1 week")
 def testMinutes2(self):
     # the timeSince() function drops the hour
     # part if the difference is in days
     t1 = DateTime('2005/04/01 12:00')
     t2 = DateTime('2005/04/01 12:01')
     difference = Utils.timeSince(t1, t2, minute_granularity=1)
     self.assertEqual(difference, "1 minute")
 def testMinutes1(self):
     # the timeSince() function drops the hour
     # part if the difference is in days
     t1 = DateTime('2005/04/01 12:00')
     t2 = DateTime('2005/04/01 12:30')
     difference = Utils.timeSince(t1, t2)
     self.assertEqual(difference, 0)
Esempio n. 7
0
 def testMinutes2(self):
     # the timeSince() function drops the hour
     # part if the difference is in days
     t1 = DateTime('2005/04/01 12:00')
     t2 = DateTime('2005/04/01 12:01')
     difference = Utils.timeSince(t1, t2, minute_granularity=1)
     self.assertEqual(difference, "1 minute")
Esempio n. 8
0
    def testWeek1(self):
        # use the week notation
        t1 = DateTime('2005/04/01')
        t2 = DateTime('2005/04/08')
        difference = Utils.timeSince(t1, t2)

        self.assertEqual(difference, "1 week")
Esempio n. 9
0
 def testPositives(self):
     T = lambda email: self.assertEqual(Utils.ValidEmailAddress(email), True
                                        )
     T('*****@*****.**')
     T(u'*****@*****.**')
     T('*****@*****.**')
     T("peter'*****@*****.**")
     T('*****@*****.**')
     T('*****@*****.**')
Esempio n. 10
0
 def testNegatives(self):
     F = lambda email: self.assertEqual(Utils.ValidEmailAddress(email),
                                        False)
     F('[email protected]')
     F('peter @fry-it.com')
     F('[email protected]')
     F(u'[email protected]')
     F('[email protected]@r.com')
     F('invalid@f#o.com')
     F('*****@*****.**')
     F('invalid@foo.')
Esempio n. 11
0
 def testDays2(self):
     t1 = DateTime('2005/04/01')
     t2 = DateTime('2005/04/03')
     difference = Utils.timeSince(t1, t2)
     self.assertEqual(difference, "2 days")
Esempio n. 12
0
 def testYears2B(self):
     t1 = DateTime('2004/01/02')
     t2 = DateTime('2002/01/01')
     difference = Utils.timeSince(t1, t2)
     self.assertEqual(difference, "2 years and 1 day")
Esempio n. 13
0
 def test2Weeks(self):
     # use the week notation
     t1 = DateTime('2005/12/08 15:54:18.715 GMT')
     t2 = DateTime('2006/01/06 10:26:18.571 GMT')
     difference = Utils.timeSince(t1, t2)
     self.assertEqual(difference, '4 weeks')
Esempio n. 14
0
 def testWeek2point1(self):
     # use the week notation
     t1 = DateTime('2005/04/01')
     t2 = DateTime('2005/04/16')
     difference = Utils.timeSince(t1, t2)
     self.assertEqual(difference, "2 weeks and 1 day")
Esempio n. 15
0
 def test2Weeks(self):
     # use the week notation
     t1 = DateTime('2005/11/12 00:08:30.937 GMT')
     t2 = DateTime('2006/01/09 09:47:07.123 GMT')
     difference = Utils.timeSince(t1, t2)
     self.assertEqual(difference, '1 month and 4 weeks')
Esempio n. 16
0
 def testBasic1(self):
     inp = "peter anders bengt"
     exp = ['peter', 'anders', 'bengt']
     self.assertEqual(Utils.splitTerms(inp), exp)
Esempio n. 17
0
 def testHours2(self):
     t1 = DateTime('2005/04/01 12:00')
     t2 = DateTime('2005/04/01 14:00')
     difference = Utils.timeSince(t1, t2)
     self.assertEqual(difference, "2 hours")
Esempio n. 18
0
 def testTwoQuotes(self):
     inp = 'peter "bengt anders" bengtsson "and again" peter'
     exp = ['peter','"bengt anders"','bengtsson',
            '"and again"','peter']
     self.assertEqual(Utils.splitTerms(inp), exp)
Esempio n. 19
0
 def testEndingQuote(self):
     inp = 'peter "bengt anders"'
     exp = ['peter','"bengt anders"']
     self.assertEqual(Utils.splitTerms(inp), exp)
Esempio n. 20
0
 def testOneQuote(self):
     inp = 'peter "bengt anders" bengtsson'
     exp = ['peter','"bengt anders"','bengtsson']
     self.assertEqual(Utils.splitTerms(inp), exp)
Esempio n. 21
0
 def testUnbalanced(self):
     inp = 'peter "bengt anders bengtsson'
     exp = ['peter','"bengt','anders','bengtsson']
     self.assertEqual(Utils.splitTerms(inp), exp)
Esempio n. 22
0
 def testBasic1(self):
     inp = "peter anders bengt"
     exp = ['peter','anders','bengt']
     self.assertEqual(Utils.splitTerms(inp), exp)
Esempio n. 23
0
 def testHours2(self):
     t1 = DateTime('2005/04/01 12:00')
     t2 = DateTime('2005/04/01 14:00')
     difference = Utils.timeSince(t1, t2)
     self.assertEqual(difference, "2 hours")
Esempio n. 24
0
 def testOneQuote(self):
     inp = 'peter "bengt anders" bengtsson'
     exp = ['peter', '"bengt anders"', 'bengtsson']
     self.assertEqual(Utils.splitTerms(inp), exp)
Esempio n. 25
0
 def testWeek2point1(self):
     # use the week notation
     t1 = DateTime('2005/04/01')
     t2 = DateTime('2005/04/16')
     difference = Utils.timeSince(t1, t2)
     self.assertEqual(difference, "2 weeks and 1 day")
Esempio n. 26
0
 def testEndingQuote(self):
     inp = 'peter "bengt anders"'
     exp = ['peter', '"bengt anders"']
     self.assertEqual(Utils.splitTerms(inp), exp)
Esempio n. 27
0
 def _find(self, text, zfill, trackerid=None, prefix=None):
     c = Utils.getFindIssueLinksRegex(zfill, trackerid, prefix)
     return c.findall(text)
Esempio n. 28
0
 def testBasic(self):
     inpu, inpp = "http://www.com", {'msg': 'foo bar'}
     exp = "http://www.com?msg=foo%20bar"
     self.assertEqual(Utils.AddParam2URL(inpu, inpp), exp)
Esempio n. 29
0
 def test2Weeks(self):
     # use the week notation
     t1 = DateTime('2005/12/08 15:54:18.715 GMT')
     t2 = DateTime('2006/01/06 10:26:18.571 GMT')
     difference = Utils.timeSince(t1, t2)
     self.assertEqual(difference, '4 weeks')
Esempio n. 30
0
 def _find(self, word, text):
     return Utils.createStandaloneWordRegex(word).findall(text)
Esempio n. 31
0
 def testStartingQuote(self):
     inp = '"bengt anders" bengtsson'
     exp = ['"bengt anders"','bengtsson']
     self.assertEqual(Utils.splitTerms(inp), exp)        
Esempio n. 32
0
 def test2Weeks(self):
     # use the week notation
     t1 = DateTime('2005/11/12 00:08:30.937 GMT')
     t2 = DateTime('2006/01/09 09:47:07.123 GMT')
     difference = Utils.timeSince(t1, t2)
     self.assertEqual(difference, '1 month and 4 weeks')
Esempio n. 33
0
 def testUnbalanced(self):
     inp = 'peter "bengt anders bengtsson'
     exp = ['peter', '"bengt', 'anders', 'bengtsson']
     self.assertEqual(Utils.splitTerms(inp), exp)
Esempio n. 34
0
 def _find(self, word, text):
     return Utils.createStandaloneWordRegex(word).findall(text)
Esempio n. 35
0
 def testTwoQuotes(self):
     inp = 'peter "bengt anders" bengtsson "and again" peter'
     exp = ['peter', '"bengt anders"', 'bengtsson', '"and again"', 'peter']
     self.assertEqual(Utils.splitTerms(inp), exp)
Esempio n. 36
0
 def testYears2A(self):
     t1 = DateTime('2005/01/01')
     # 2004 was a leap year
     t2 = DateTime('2003/01/02')
     difference = Utils.timeSince(t1, t2)
     self.assertEqual(difference, "2 years")
Esempio n. 37
0
 def testStartingQuote(self):
     inp = '"bengt anders" bengtsson'
     exp = ['"bengt anders"', 'bengtsson']
     self.assertEqual(Utils.splitTerms(inp), exp)
Esempio n. 38
0
 def testYears2B(self):
     t1 = DateTime('2004/01/02')
     t2 = DateTime('2002/01/01')
     difference = Utils.timeSince(t1, t2)
     self.assertEqual(difference, "2 years and 1 day")
Esempio n. 39
0
 def testBasicPlus(self):
     inpu, inpp = "http://www.com", {'msg': 'foo bar'}
     exp = "http://www.com?msg=foo+bar"
     self.assertEqual(Utils.AddParam2URL(inpu, inpp, plus_quote=1), exp)
Esempio n. 40
0
 def testYears3B(self):
     t1 = DateTime('2004/02/01')
     # 2004 was a leap year
     t2 = DateTime('2002/01/01')
     difference = Utils.timeSince(t1, t2)
     self.assertEqual(difference, "2 years and 1 month and 1 day")
Esempio n. 41
0
 def testMonths(self):
     t1 = DateTime('2005/04/01')
     t2 = DateTime('2005/05/01')
     difference = Utils.timeSince(t1, t2)
     self.assertEqual(difference, "1 month")
Esempio n. 42
0
 def _find(self, text, zfill, trackerid=None, prefix=None):
     c = Utils.getFindIssueLinksRegex(zfill, trackerid, prefix)
     return c.findall(text)
Esempio n. 43
0
 def testYears2A(self):
     t1 = DateTime('2005/01/01')
     # 2004 was a leap year
     t2 = DateTime('2003/01/02')
     difference = Utils.timeSince(t1, t2)
     self.assertEqual(difference, "2 years")
Esempio n. 44
0
 def testDays2(self):
     t1 = DateTime('2005/04/01')
     t2 = DateTime('2005/04/03')
     difference = Utils.timeSince(t1, t2)
     self.assertEqual(difference, "2 days")
Esempio n. 45
0
 def testYears3B(self):
     t1 = DateTime('2004/02/01')
     # 2004 was a leap year
     t2 = DateTime('2002/01/01')
     difference = Utils.timeSince(t1, t2)
     self.assertEqual(difference, "2 years and 1 month and 1 day")
Esempio n. 46
0
 def testMonths(self):
     t1 = DateTime('2005/04/01')
     t2 = DateTime('2005/05/01')
     difference = Utils.timeSince(t1, t2)
     self.assertEqual(difference, "1 month")