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