Example #1
0
    def changes_since(self, domain, date_or_datetime):
        """
        Gets the changes for a domain since the specified date/datetime.
        The date can be one of:
            - a Python datetime object
            - a Python date object
            - a string in the format 'YYYY-MM-YY HH:MM:SS'
            - a string in the format 'YYYY-MM-YY'

        It returns a list of dicts, whose keys depend on the specific change
        that was made. A simple example of such a change dict:

            {u'accountId': 000000,
             u'action': u'update',
             u'changeDetails': [{u'field': u'serial_number',
               u'newValue': u'1354038941',
               u'originalValue': u'1354038940'},
              {u'field': u'updated_at',
               u'newValue': u'Tue Nov 27 17:55:41 UTC 2012',
               u'originalValue': u'Tue Nov 27 17:55:40 UTC 2012'}],
             u'domain': u'example.com',
             u'targetId': 00000000,
             u'targetType': u'Domain'}
        """
        domain_id = utils.get_id(domain)
        dt = utils.iso_time_string(date_or_datetime, show_tzinfo=True)
        uri = "/domains/%s/changes?since=%s" % (domain_id, dt)
        resp, body = self.api.method_get(uri)
        return body.get("changes", [])
Example #2
0
    def changes_since(self, domain, date_or_datetime):
        """
        Gets the changes for a domain since the specified date/datetime.
        The date can be one of:
            - a Python datetime object
            - a Python date object
            - a string in the format 'YYYY-MM-YY HH:MM:SS'
            - a string in the format 'YYYY-MM-YY'

        It returns a list of dicts, whose keys depend on the specific change
        that was made. A simple example of such a change dict:

            {u'accountId': 000000,
             u'action': u'update',
             u'changeDetails': [{u'field': u'serial_number',
               u'newValue': u'1354038941',
               u'originalValue': u'1354038940'},
              {u'field': u'updated_at',
               u'newValue': u'Tue Nov 27 17:55:41 UTC 2012',
               u'originalValue': u'Tue Nov 27 17:55:40 UTC 2012'}],
             u'domain': u'example.com',
             u'targetId': 00000000,
             u'targetType': u'Domain'}
        """
        domain_id = utils.get_id(domain)
        dt = utils.iso_time_string(date_or_datetime, show_tzinfo=True)
        uri = "/domains/%s/changes?since=%s" % (domain_id, dt)
        resp, body = self.api.method_get(uri)
        return body.get("changes", [])
Example #3
0
    def test_time_string_datetime_hide_tz(self):
        class TZ(datetime.tzinfo):
            def utcoffset(self, dt):
                return datetime.timedelta(minutes=-120)

        dt = datetime.datetime(1999, 12, 31, 23, 59, 59, tzinfo=TZ())
        self.assertEqual(utils.iso_time_string(dt, show_tzinfo=False), "1999-12-31T23:59:59")
Example #4
0
    def test_time_string_datetime_hide_tz(self):
        class TZ(datetime.tzinfo):
            def utcoffset(self, dt):
                return datetime.timedelta(minutes=-120)

        dt = datetime.datetime(1999, 12, 31, 23, 59, 59, tzinfo=TZ())
        self.assertEqual(utils.iso_time_string(dt, show_tzinfo=False),
                         "1999-12-31T23:59:59")
Example #5
0
 def test_time_string_datetime_add_tz(self):
     dt = "1999-12-31 23:59:59"
     self.assertEqual(utils.iso_time_string(dt, show_tzinfo=True),
             "1999-12-31T23:59:59+0000")
Example #6
0
 def test_time_string_datetime(self):
     dt = "1999-12-31 23:59:59"
     self.assertEqual(utils.iso_time_string(dt), "1999-12-31T23:59:59")
Example #7
0
 def test_time_string_date_obj(self):
     dt = datetime.date(1999, 12, 31)
     self.assertEqual(utils.iso_time_string(dt), "1999-12-31T00:00:00")
Example #8
0
 def test_time_string_date(self):
     dt = "1999-12-31"
     iso = utils.iso_time_string(dt)
     self.assertEqual(iso, "1999-12-31T00:00:00")
Example #9
0
 def test_time_string_empty(self):
     testval = None
     self.assertEqual(utils.iso_time_string(testval), "")
Example #10
0
 def test_time_string_datetime_add_tz(self):
     dt = "1999-12-31 23:59:59"
     self.assertEqual(utils.iso_time_string(dt, show_tzinfo=True),
                      "1999-12-31T23:59:59+0000")
Example #11
0
 def test_time_string_datetime(self):
     dt = "1999-12-31 23:59:59"
     self.assertEqual(utils.iso_time_string(dt), "1999-12-31T23:59:59")
Example #12
0
 def test_time_string_date_obj(self):
     dt = datetime.date(1999, 12, 31)
     self.assertEqual(utils.iso_time_string(dt), "1999-12-31T00:00:00")
Example #13
0
 def test_time_string_date(self):
     dt = "1999-12-31"
     self.assertEqual(utils.iso_time_string(dt), "1999-12-31T00:00:00")
Example #14
0
 def test_time_string_empty(self):
     testval = None
     self.assertEqual(utils.iso_time_string(testval), "")