aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2020-04-24 09:42:44 +0200
committerMichał Górny <mgorny@gentoo.org>2020-04-24 09:42:44 +0200
commit1a18160c8200fb444878538b127b30bb461e4c42 (patch)
treef946012d9ac793eeafe7b794009747868475814c /pym/gentoolkit/test
parenteuse: don't fail on repos missing use.desc (diff)
downloadgentoolkit-1a18160c8200fb444878538b127b30bb461e4c42.tar.gz
gentoolkit-1a18160c8200fb444878538b127b30bb461e4c42.tar.bz2
gentoolkit-1a18160c8200fb444878538b127b30bb461e4c42.zip
Extract profile reading code from eshowkw, with tests from ekeyword
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'pym/gentoolkit/test')
-rw-r--r--pym/gentoolkit/test/test_profile.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/pym/gentoolkit/test/test_profile.py b/pym/gentoolkit/test/test_profile.py
new file mode 100644
index 0000000..038525d
--- /dev/null
+++ b/pym/gentoolkit/test/test_profile.py
@@ -0,0 +1,49 @@
+#!/usr/bin/python
+# Copyright 2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+#
+# Licensed under the GNU General Public License, v2
+
+import os.path
+import unittest
+
+from gentoolkit.profile import load_profile_data
+
+
+TESTDIR = os.path.join(os.path.dirname(__file__), '../ekeyword/tests')
+
+
+class TestLoadProfileData(unittest.TestCase):
+ """Tests for load_profile_data"""
+
+ def _test(self, subdir):
+ portdir = os.path.join(TESTDIR, 'profiles', subdir)
+ return load_profile_data(portdir=portdir)
+
+ def testLoadBoth(self):
+ """Test loading both arch.list and profiles.desc"""
+ ret = self._test('both')
+ self.assertIn('arm', ret)
+ self.assertEqual(ret['arm'], ('stable', 'arch'))
+ self.assertIn('arm64', ret)
+ self.assertEqual(ret['arm64'], ('exp', 'arch'))
+
+ def testLoadArchOnly(self):
+ """Test loading only arch.list"""
+ ret = self._test('arch-only')
+ self.assertIn('arm', ret)
+ self.assertEqual(ret['arm'], (None, 'arch'))
+ self.assertIn('x86-solaris', ret)
+
+ def testLoadProfilesOnly(self):
+ """Test loading only profiles.desc"""
+ ret = self._test('profiles-only')
+ self.assertIn('arm', ret)
+ self.assertEqual(ret['arm'], ('stable', 'arch'))
+ self.assertIn('arm64', ret)
+ self.assertEqual(ret['arm64'], ('exp', 'arch'))
+
+ def testLoadNone(self):
+ """Test running when neither files exists"""
+ ret = self._test('none')
+ self.assertEqual(ret, {})