Пример #1
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')
Пример #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')
Пример #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)
Пример #4
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")
Пример #5
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")
Пример #6
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)
Пример #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")
Пример #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")
Пример #9
0
 def testPositives(self):
     T = lambda email: self.assertEqual(Utils.ValidEmailAddress(email), True
                                        )
     T('*****@*****.**')
     T(u'*****@*****.**')
     T('*****@*****.**')
     T("peter'*****@*****.**")
     T('*****@*****.**')
     T('*****@*****.**')
Пример #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.')
Пример #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")
Пример #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")
Пример #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')
Пример #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")
Пример #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')
Пример #16
0
 def testBasic1(self):
     inp = "peter anders bengt"
     exp = ['peter', 'anders', 'bengt']
     self.assertEqual(Utils.splitTerms(inp), exp)
Пример #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")
Пример #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)
Пример #19
0
 def testEndingQuote(self):
     inp = 'peter "bengt anders"'
     exp = ['peter','"bengt anders"']
     self.assertEqual(Utils.splitTerms(inp), exp)
Пример #20
0
 def testOneQuote(self):
     inp = 'peter "bengt anders" bengtsson'
     exp = ['peter','"bengt anders"','bengtsson']
     self.assertEqual(Utils.splitTerms(inp), exp)
Пример #21
0
 def testUnbalanced(self):
     inp = 'peter "bengt anders bengtsson'
     exp = ['peter','"bengt','anders','bengtsson']
     self.assertEqual(Utils.splitTerms(inp), exp)
Пример #22
0
 def testBasic1(self):
     inp = "peter anders bengt"
     exp = ['peter','anders','bengt']
     self.assertEqual(Utils.splitTerms(inp), exp)
Пример #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")
Пример #24
0
 def testOneQuote(self):
     inp = 'peter "bengt anders" bengtsson'
     exp = ['peter', '"bengt anders"', 'bengtsson']
     self.assertEqual(Utils.splitTerms(inp), exp)
Пример #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")
Пример #26
0
 def testEndingQuote(self):
     inp = 'peter "bengt anders"'
     exp = ['peter', '"bengt anders"']
     self.assertEqual(Utils.splitTerms(inp), exp)
Пример #27
0
 def _find(self, text, zfill, trackerid=None, prefix=None):
     c = Utils.getFindIssueLinksRegex(zfill, trackerid, prefix)
     return c.findall(text)
Пример #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)
Пример #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')
Пример #30
0
 def _find(self, word, text):
     return Utils.createStandaloneWordRegex(word).findall(text)
Пример #31
0
 def testStartingQuote(self):
     inp = '"bengt anders" bengtsson'
     exp = ['"bengt anders"','bengtsson']
     self.assertEqual(Utils.splitTerms(inp), exp)        
Пример #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')
Пример #33
0
 def testUnbalanced(self):
     inp = 'peter "bengt anders bengtsson'
     exp = ['peter', '"bengt', 'anders', 'bengtsson']
     self.assertEqual(Utils.splitTerms(inp), exp)
Пример #34
0
 def _find(self, word, text):
     return Utils.createStandaloneWordRegex(word).findall(text)
Пример #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)
Пример #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")
Пример #37
0
 def testStartingQuote(self):
     inp = '"bengt anders" bengtsson'
     exp = ['"bengt anders"', 'bengtsson']
     self.assertEqual(Utils.splitTerms(inp), exp)
Пример #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")
Пример #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)
Пример #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")
Пример #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")
Пример #42
0
 def _find(self, text, zfill, trackerid=None, prefix=None):
     c = Utils.getFindIssueLinksRegex(zfill, trackerid, prefix)
     return c.findall(text)
Пример #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")
Пример #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")
Пример #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")
Пример #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")