api: payload_unittest.py: Move payload cache directory.

Running the chromite unit tests leaves behind the payload cache dir.
Patch the payload cache directory with a tempdir for the unittests
to avoid the orphaned directory. Add TODO for investigating more
permanent solutions.

BUG=b:223433932
TEST=run_tests does not leave behind .paygen_cache

Change-Id: I0acb8fff9c811f9a836636a7b934ea5126915294
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/3858036
Auto-Submit: Alex Klein <saklein@chromium.org>
Reviewed-by: Sloan Johnson <sloanjohnson@google.com>
Tested-by: Alex Klein <saklein@chromium.org>
Commit-Queue: Sloan Johnson <sloanjohnson@google.com>
Commit-Queue: Alex Klein <saklein@chromium.org>
diff --git a/api/controller/payload_unittest.py b/api/controller/payload_unittest.py
index 2b9254d..9b86630 100644
--- a/api/controller/payload_unittest.py
+++ b/api/controller/payload_unittest.py
@@ -13,7 +13,8 @@
 from chromite.lib.paygen import paygen_payload_lib
 
 
-class PayloadApiTests(cros_test_lib.MockTestCase, api_config.ApiConfigMixin):
+class PayloadApiTests(cros_test_lib.MockTempDirTestCase,
+                      api_config.ApiConfigMixin):
   """Unittests for PayloadApi."""
 
   def setUp(self):
@@ -55,6 +56,9 @@
         local_path='/tmp/aohiwdadoi/delta.bin',
         remote_uri='gs://something')
 
+    self.PatchObject(payload, '_DEFAULT_PAYGEN_CACHE_DIR',
+                     new=str(self.tempdir))
+
   def testValidateOnly(self):
     """Basic check that a validate only call does not execute any logic."""