def test_props_set_by_server(self): import datetime from gcloud._helpers import UTC from gcloud._helpers import _millis CREATED = datetime.datetime(2015, 8, 11, 12, 13, 22, tzinfo=UTC) STARTED = datetime.datetime(2015, 8, 11, 13, 47, 15, tzinfo=UTC) ENDED = datetime.datetime(2015, 8, 11, 14, 47, 15, tzinfo=UTC) JOB_ID = "%s:%s" % (self.PROJECT, self.JOB_NAME) URL = "http://example.com/projects/%s/jobs/%s" % (self.PROJECT, self.JOB_NAME) EMAIL = "*****@*****.**" ERROR_RESULT = {"debugInfo": "DEBUG", "location": "LOCATION", "message": "MESSAGE", "reason": "REASON"} client = _Client(self.PROJECT) table = _Table() job = self._makeOne(self.JOB_NAME, table, [self.SOURCE1], client) job._properties["etag"] = "ETAG" job._properties["id"] = JOB_ID job._properties["selfLink"] = URL job._properties["user_email"] = EMAIL statistics = job._properties["statistics"] = {} statistics["creationTime"] = _millis(CREATED) statistics["startTime"] = _millis(STARTED) statistics["endTime"] = _millis(ENDED) load_stats = statistics["load"] = {} load_stats["inputFileBytes"] = 12345 load_stats["inputFiles"] = 1 load_stats["outputBytes"] = 23456 load_stats["outputRows"] = 345 self.assertEqual(job.etag, "ETAG") self.assertEqual(job.job_id, JOB_ID) self.assertEqual(job.self_link, URL) self.assertEqual(job.user_email, EMAIL) self.assertEqual(job.created, CREATED) self.assertEqual(job.started, STARTED) self.assertEqual(job.ended, ENDED) self.assertEqual(job.input_file_bytes, 12345) self.assertEqual(job.input_files, 1) self.assertEqual(job.output_bytes, 23456) self.assertEqual(job.output_rows, 345) status = job._properties["status"] = {} self.assertEqual(job.error_result, None) self.assertEqual(job.errors, None) self.assertEqual(job.state, None) status["errorResult"] = ERROR_RESULT status["errors"] = [ERROR_RESULT] status["state"] = "STATE" self.assertEqual(job.error_result, ERROR_RESULT) self.assertEqual(job.errors, [ERROR_RESULT]) self.assertEqual(job.state, "STATE")
def _callFUT(self, value): from gcloud._helpers import _millis return _millis(value)
def test_props_set_by_server(self): import datetime from gcloud._helpers import UTC from gcloud._helpers import _millis CREATED = datetime.datetime(2015, 8, 11, 12, 13, 22, tzinfo=UTC) STARTED = datetime.datetime(2015, 8, 11, 13, 47, 15, tzinfo=UTC) ENDED = datetime.datetime(2015, 8, 11, 14, 47, 15, tzinfo=UTC) JOB_ID = '%s:%s' % (self.PROJECT, self.JOB_NAME) URL = 'http://example.com/projects/%s/jobs/%s' % (self.PROJECT, self.JOB_NAME) EMAIL = '*****@*****.**' ERROR_RESULT = { 'debugInfo': 'DEBUG', 'location': 'LOCATION', 'message': 'MESSAGE', 'reason': 'REASON' } client = _Client(self.PROJECT) table = _Table() job = self._makeOne(self.JOB_NAME, table, [self.SOURCE1], client) job._properties['etag'] = 'ETAG' job._properties['id'] = JOB_ID job._properties['selfLink'] = URL job._properties['user_email'] = EMAIL statistics = job._properties['statistics'] = {} statistics['creationTime'] = _millis(CREATED) statistics['startTime'] = _millis(STARTED) statistics['endTime'] = _millis(ENDED) load_stats = statistics['load'] = {} load_stats['inputFileBytes'] = 12345 load_stats['inputFiles'] = 1 load_stats['outputBytes'] = 23456 load_stats['outputRows'] = 345 self.assertEqual(job.etag, 'ETAG') self.assertEqual(job.job_id, JOB_ID) self.assertEqual(job.self_link, URL) self.assertEqual(job.user_email, EMAIL) self.assertEqual(job.created, CREATED) self.assertEqual(job.started, STARTED) self.assertEqual(job.ended, ENDED) self.assertEqual(job.input_file_bytes, 12345) self.assertEqual(job.input_files, 1) self.assertEqual(job.output_bytes, 23456) self.assertEqual(job.output_rows, 345) status = job._properties['status'] = {} self.assertEqual(job.error_result, None) self.assertEqual(job.errors, None) self.assertEqual(job.state, None) status['errorResult'] = ERROR_RESULT status['errors'] = [ERROR_RESULT] status['state'] = 'STATE' self.assertEqual(job.error_result, ERROR_RESULT) self.assertEqual(job.errors, [ERROR_RESULT]) self.assertEqual(job.state, 'STATE')
def test_props_set_by_server(self): import datetime from gcloud._helpers import UTC from gcloud._helpers import _millis CREATED = datetime.datetime(2015, 8, 11, 12, 13, 22, tzinfo=UTC) STARTED = datetime.datetime(2015, 8, 11, 13, 47, 15, tzinfo=UTC) ENDED = datetime.datetime(2015, 8, 11, 14, 47, 15, tzinfo=UTC) JOB_ID = '%s:%s' % (self.PROJECT, self.JOB_NAME) URL = 'http://example.com/projects/%s/jobs/%s' % ( self.PROJECT, self.JOB_NAME) EMAIL = '*****@*****.**' ERROR_RESULT = {'debugInfo': 'DEBUG', 'location': 'LOCATION', 'message': 'MESSAGE', 'reason': 'REASON'} client = _Client(self.PROJECT) table = _Table() job = self._makeOne(self.JOB_NAME, table, [self.SOURCE1], client) job._properties['etag'] = 'ETAG' job._properties['id'] = JOB_ID job._properties['selfLink'] = URL job._properties['user_email'] = EMAIL statistics = job._properties['statistics'] = {} statistics['creationTime'] = _millis(CREATED) statistics['startTime'] = _millis(STARTED) statistics['endTime'] = _millis(ENDED) load_stats = statistics['load'] = {} load_stats['inputFileBytes'] = 12345 load_stats['inputFiles'] = 1 load_stats['outputBytes'] = 23456 load_stats['outputRows'] = 345 self.assertEqual(job.etag, 'ETAG') self.assertEqual(job.job_id, JOB_ID) self.assertEqual(job.self_link, URL) self.assertEqual(job.user_email, EMAIL) self.assertEqual(job.created, CREATED) self.assertEqual(job.started, STARTED) self.assertEqual(job.ended, ENDED) self.assertEqual(job.input_file_bytes, 12345) self.assertEqual(job.input_files, 1) self.assertEqual(job.output_bytes, 23456) self.assertEqual(job.output_rows, 345) status = job._properties['status'] = {} self.assertEqual(job.error_result, None) self.assertEqual(job.errors, None) self.assertEqual(job.state, None) status['errorResult'] = ERROR_RESULT status['errors'] = [ERROR_RESULT] status['state'] = 'STATE' self.assertEqual(job.error_result, ERROR_RESULT) self.assertEqual(job.errors, [ERROR_RESULT]) self.assertEqual(job.state, 'STATE')