def test_date_to_iso8601(self): date = datetime.datetime(2014, 3, 22, 00, 00, 00, 0, tzinfo=pytz.UTC) result = date_to_iso8601(date) expected = "2014-03-22T00%3A00%3A00%2B00%3A00" self.assertEquals(result, expected) date = datetime.datetime(2014, 3, 22, 00, 00, 00, 0, tzinfo=pytz.timezone("America/Phoenix")) result = date_to_iso8601(date) expected = "2014-03-22T00%3A00%3A00-07%3A00" self.assertEquals(result, expected)
def test_date_to_iso8601(self): date = datetime.datetime(2014, 3, 22, 00, 00, 00, 0, tzinfo=pytz.UTC) result = date_to_iso8601(date) expected = '2014-03-22T00%3A00%3A00%2B00%3A00' self.assertEquals(result, expected) date = datetime.datetime(2014, 3, 22, 00, 00, 00, 0, tzinfo=pytz.timezone('America/Chicago')) result = date_to_iso8601(date) expected = '2014-03-22T00%3A00%3A00-06%3A00' self.assertEquals(result, expected)
def deleted(self, start, end): """Use the SObject Get Deleted resource to get a list of deleted records for the specified object. .../deleted/?start=2013-05-05T00:00:00+00:00&end=2013-05-10T00:00:00+00:00 * start -- start datetime object * end -- end datetime object """ url = self.base_url + 'deleted/?start={start}&end={end}'.format( start=date_to_iso8601(start), end=date_to_iso8601(end)) result = self._call_salesforce('GET', url) return result.json(object_pairs_hook=OrderedDict)
def test_date_to_iso8601(self): date = pytz.UTC.localize(datetime.datetime(2014, 3, 22, 00, 00, 00, 0)) result = date_to_iso8601(date) expected = '2014-03-22T00%3A00%3A00%2B00%3A00' self.assertEquals(result, expected) date = pytz.timezone('America/Phoenix').localize( datetime.datetime(2014, 3, 22, 00, 00, 00, 0)) result = date_to_iso8601(date) expected = '2014-03-22T00%3A00%3A00-07%3A00' self.assertEquals(result, expected)
def test_date_to_iso8601(self): """Test date conversion""" # pylint: disable=no-value-for-parameter date = pytz.UTC.localize(datetime.datetime(2014, 3, 22, 00, 00, 00, 0)) result = date_to_iso8601(date) expected = '2014-03-22T00%3A00%3A00%2B00%3A00' self.assertEqual(result, expected) date = pytz.timezone('America/Phoenix').localize( datetime.datetime(2014, 3, 22, 00, 00, 00, 0)) result = date_to_iso8601(date) expected = '2014-03-22T00%3A00%3A00-07%3A00' self.assertEqual(result, expected)
def updated(self, start, end): """Use the SObject Get Updated resource to get a list of updated (modified or added) records for the specified object. .../updated/?start=2014-03-20T00:00:00+00:00&end=2014-03-22T00:00:00+00:00 * start -- start datetime object * end -- end datetime object """ url = self.base_url + "updated/?start={start}&end={end}".format( start=date_to_iso8601(start), end=date_to_iso8601(end) ) result = self._call_salesforce("GET", url) return result.json(object_pairs_hook=OrderedDict)
def updated(self, start, end): # pylint: disable=line-too-long """Gets a list of updated records Use the SObject Get Updated resource to get a list of updated (modified or added) records for the specified object. .../updated/?start=2014-03-20T00:00:00+00:00&end=2014-03-22T00:00:00+00:00 * start -- start datetime object * end -- end datetime object """ url = self.base_url + 'updated/?start={start}&end={end}'.format( start=date_to_iso8601(start), end=date_to_iso8601(end)) result = self._call_salesforce('GET', url) return result.json(object_pairs_hook=OrderedDict)
def updated(self, start, end): """Use the SObject Get Updated resource to get a list of updated (modified or added) records for the specified object. .../updated/?start=2014-03-20T00:00:00+00:00&end=2014-03-22T00:00:00+00:00 * start -- start datetime object * end -- end datetime object """ url = self.base_url + 'updated/?start={start}&end={end}'.format( start=date_to_iso8601(start), end=date_to_iso8601(end)) result = self._call_salesforce('GET', url) #Python 2.6 doesn't like OrderedDict if sys.version_info[0:2] <= (2, 6): return result.json() return result.json(object_pairs_hook=OrderedDict)
def deleted(self, start, end, headers=None): # pylint: disable=line-too-long """Gets a list of deleted records Use the SObject Get Deleted resource to get a list of deleted records for the specified object. .../deleted/?start=2013-05-05T00:00:00+00:00&end=2013-05-10T00:00:00+00:00 * start -- start datetime object * end -- end datetime object * headers -- a dict with additional request headers. """ url = urljoin( self.base_url, 'deleted/?start={start}&end={end}'.format( start=date_to_iso8601(start), end=date_to_iso8601(end))) result = self._call_salesforce(method='GET', url=url, headers=headers) return result.json(object_pairs_hook=OrderedDict)
def deleted(self, start, end, **kwargs): # pylint: disable=line-too-long """Gets a list of deleted records Use the SObject Get Deleted resource to get a list of deleted records for the specified object. .../deleted/?start=2013-05-05T00:00:00+00:00&end=2013-05-10T00:00:00+00:00 * start -- start datetime object * end -- end datetime object * kwargs -- Parameters passed down to `requests.Session.request` method """ url = urljoin( self.base_url, 'deleted/?start={start}&end={end}'.format( start=date_to_iso8601(start), end=date_to_iso8601(end))) result = self._call_salesforce(method='GET', url=url, **kwargs) return result.json(object_pairs_hook=OrderedDict)
def updated(self, start, end): # pylint: disable=line-too-long """Gets a list of updated records Use the SObject Get Updated resource to get a list of updated (modified or added) records for the specified object. .../updated/?start=2014-03-20T00:00:00+00:00&end=2014-03-22T00:00:00+00:00 * start -- start datetime object * end -- end datetime object """ url = self.base_url + 'updated/?start={start}&end={end}'.format( start=date_to_iso8601(start), end=date_to_iso8601(end)) result = self._call_salesforce('GET', url) #return result.json(object_pairs_hook=OrderedDict) return result.json()
def deleted(self, start, end, headers=None): # pylint: disable=line-too-long """Gets a list of deleted records Use the SObject Get Deleted resource to get a list of deleted records for the specified object. .../deleted/?start=2013-05-05T00:00:00+00:00&end=2013-05-10T00:00:00+00:00 * start -- start datetime object * end -- end datetime object * headers -- a dict with additional request headers. """ url = urljoin( self.base_url, 'deleted/?start={start}&end={end}'.format( start=date_to_iso8601(start), end=date_to_iso8601(end) ) ) result = self._call_salesforce(method='GET', url=url, headers=headers) return result.json(object_pairs_hook=OrderedDict)