class TestProvideLastModifiedTimeSubscriber(BaseTestWithFileCreator): def setUp(self): super(TestProvideLastModifiedTimeSubscriber, self).setUp() self.filename = self.file_creator.create_file("myfile", "my contents") self.desired_utime = datetime.datetime(2016, 1, 18, 7, 0, 0, tzinfo=tzlocal()) self.result_queue = queue.Queue() self.subscriber = ProvideLastModifiedTimeSubscriber(self.desired_utime, self.result_queue) call_args = FakeTransferFutureCallArgs(fileobj=self.filename) meta = FakeTransferFutureMeta(call_args=call_args) self.future = FakeTransferFuture(meta=meta) def test_on_success_modifies_utime(self): self.subscriber.on_done(self.future) _, utime = get_file_stat(self.filename) self.assertEqual(utime, self.desired_utime) def test_on_success_failure_in_utime_mod_raises_warning(self): self.subscriber = ProvideLastModifiedTimeSubscriber(None, self.result_queue) self.subscriber.on_done(self.future) # Because the time to provide was None it will throw an exception # which results in the a warning about the utime not being able # to be set being placed in the result queue. result = self.result_queue.get() self.assertIsInstance(result, WarningResult) self.assertIn("unable to update the last modified time", result.message)
class TestProvideLastModifiedTimeSubscriber(BaseTestWithFileCreator): def setUp(self): super(TestProvideLastModifiedTimeSubscriber, self).setUp() self.filename = self.file_creator.create_file('myfile', 'my contents') self.desired_utime = datetime.datetime(2016, 1, 18, 7, 0, 0, tzinfo=tzlocal()) self.result_queue = queue.Queue() self.subscriber = ProvideLastModifiedTimeSubscriber( self.desired_utime, self.result_queue) call_args = FakeTransferFutureCallArgs(fileobj=self.filename) meta = FakeTransferFutureMeta(call_args=call_args) self.future = FakeTransferFuture(meta=meta) def test_on_success_modifies_utime(self): self.subscriber.on_done(self.future) _, utime = get_file_stat(self.filename) self.assertEqual(utime, self.desired_utime) def test_on_success_failure_in_utime_mod_raises_warning(self): self.subscriber = ProvideLastModifiedTimeSubscriber( None, self.result_queue) self.subscriber.on_done(self.future) # Because the time to provide was None it will throw an exception # which results in the a warning about the utime not being able # to be set being placed in the result queue. result = self.result_queue.get() self.assertIsInstance(result, WarningResult) self.assertIn('unable to update the last modified time', result.message)