update: fully isolate testInsertStoreMetadata test

The test was failing due to something on my local filesystem, this
runs the test in a new dir every time.
This commit is contained in:
Hans-Christoph Steiner 2022-09-05 20:46:32 +02:00
parent e79585b0c0
commit b854f3bab7

View file

@ -88,28 +88,49 @@ class UpdateTest(unittest.TestCase):
fdroidserver.common.config = None fdroidserver.common.config = None
fdroidserver.common.options = None fdroidserver.common.options = None
def testInsertStoreMetadata(self): def test_insert_store_metadata(self):
tmptestsdir = tempfile.mkdtemp(
prefix=inspect.currentframe().f_code.co_name, dir=self.tmpdir
)
os.chdir(tmptestsdir)
config = dict() config = dict()
fdroidserver.common.fill_config_defaults(config) fdroidserver.common.fill_config_defaults(config)
fdroidserver.update.config = config fdroidserver.update.config = config
os.chdir(os.path.join(localmodule, 'tests'))
shutil.rmtree(os.path.join('repo', 'info.guardianproject.urzip'), ignore_errors=True) repo_dir = os.path.join(self.basedir, 'repo')
os.mkdir('metadata')
shutil.rmtree(os.path.join('build', 'com.nextcloud.client'), ignore_errors=True) for packageName in (
shutil.copytree(os.path.join('source-files', 'com.nextcloud.client'), 'obb.mainpatch.current',
os.path.join('build', 'com.nextcloud.client')) 'org.videolan.vlc',
):
shutil.rmtree(os.path.join('build', 'com.nextcloud.client.dev'), ignore_errors=True) shutil.copytree(
shutil.copytree(os.path.join('source-files', 'com.nextcloud.client.dev'), os.path.join(repo_dir, packageName),
os.path.join('build', 'com.nextcloud.client.dev')) os.path.join('repo', packageName)
)
shutil.rmtree(os.path.join('build', 'eu.siacs.conversations'), ignore_errors=True) for packageName in (
shutil.copytree(os.path.join('source-files', 'eu.siacs.conversations'), 'info.guardianproject.checkey',
os.path.join('build', 'eu.siacs.conversations')) 'info.guardianproject.urzip',
'org.smssecure.smssecure',
):
if not os.path.exists('metadata'):
os.mkdir('metadata')
shutil.copytree(
os.path.join(self.basedir, 'metadata', packageName),
os.path.join('metadata', packageName)
)
for packageName in (
'com.nextcloud.client',
'com.nextcloud.client.dev',
'eu.siacs.conversations',
):
shutil.copytree(
os.path.join(self.basedir, 'source-files', packageName),
os.path.join(tmptestsdir, 'build', packageName),
)
testfilename = 'icon_yAfSvPRJukZzMMfUzvbYqwaD1XmHXNtiPBtuPVHW-6s=.png' testfilename = 'icon_yAfSvPRJukZzMMfUzvbYqwaD1XmHXNtiPBtuPVHW-6s=.png'
testfile = os.path.join('repo', 'org.videolan.vlc', 'en-US', 'icon.png') testfile = os.path.join(repo_dir, 'org.videolan.vlc', 'en-US', 'icon.png')
cpdir = os.path.join('metadata', 'org.videolan.vlc', 'en-US') cpdir = os.path.join('metadata', 'org.videolan.vlc', 'en-US')
cpfile = os.path.join(cpdir, testfilename) cpfile = os.path.join(cpdir, testfilename)
os.makedirs(cpdir, exist_ok=True) os.makedirs(cpdir, exist_ok=True)
@ -155,7 +176,7 @@ class UpdateTest(unittest.TestCase):
self.assertEqual(6, len(apps)) self.assertEqual(6, len(apps))
for packageName, app in apps.items(): for packageName, app in apps.items():
self.assertTrue('localized' in app) self.assertTrue('localized' in app, packageName)
self.assertTrue('en-US' in app['localized']) self.assertTrue('en-US' in app['localized'])
self.assertEqual(1, len(app['localized'])) self.assertEqual(1, len(app['localized']))
if packageName == 'info.guardianproject.urzip': if packageName == 'info.guardianproject.urzip':