[dak/master] extract_component_from_section: Drop unnecessary session parameter
Signed-off-by: Niels Thykier <niels@thykier.net>
---
daklib/utils.py | 2 +-
tests/dbtest_extract_component_from_section.py | 60 --------------------------
tests/test_utils.py | 17 +++++++-
3 files changed, 17 insertions(+), 62 deletions(-)
delete mode 100755 tests/dbtest_extract_component_from_section.py
diff --git a/daklib/utils.py b/daklib/utils.py
index e0f00ce..9891871 100644
--- a/daklib/utils.py
+++ b/daklib/utils.py
@@ -143,7 +143,7 @@ def our_raw_input(prompt=""):
################################################################################
-def extract_component_from_section(section, session=None):
+def extract_component_from_section(section):
component = ""
if section.find('/') != -1:
diff --git a/tests/dbtest_extract_component_from_section.py b/tests/dbtest_extract_component_from_section.py
deleted file mode 100755
index b389ad1..0000000
--- a/tests/dbtest_extract_component_from_section.py
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/usr/bin/env python
-
-from db_test import DBDakTestCase
-
-import unittest
-
-from daklib.utils import extract_component_from_section
-
-class ExtractComponentTestCase(DBDakTestCase):
- """
- prefix: non-US
- component: main, contrib, non-free
- section: games, admin, libs, [...]
-
- [1] Order is as above.
- [2] Prefix is optional for the default archive, but mandatory when
- uploads are going anywhere else.
- [3] Default component is main and may be omitted.
- [4] Section is optional.
- [5] Prefix is case insensitive
- [6] Everything else is case sensitive.
- """
-
- def assertExtract(self, input, output):
- self.setup_components()
- self.assertEqual(
- extract_component_from_section(input, self.session)[1],
- output,
- )
-
- def test_1(self):
- # Validate #3
- self.assertExtract('utils', 'main')
-
- def test_2(self):
- # Err, whoops? should probably be 'utils', 'main'...
- self.assertExtract('main/utils', 'main')
-
- def test_3(self):
- self.assertExtract('non-free/libs', 'non-free')
-
- def test_4(self):
- self.assertExtract('contrib/net', 'contrib')
-
- def test_5(self):
- # Validate #4
- self.assertExtract('main', 'main')
-
- def test_6(self):
- self.assertExtract('contrib', 'contrib')
-
- def test_7(self):
- self.assertExtract('non-free', 'non-free')
-
- def test_8(self):
- # Validate #6 (section)
- self.assertExtract('utIls', 'main')
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 1bbf167..bd65b8d 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -21,7 +21,8 @@ import unittest
from base_test import DakTestCase
from daklib.utils import (arch_compare_sw, is_in_debug_section,
- parse_built_using)
+ parse_built_using,
+ extract_component_from_section)
apt_pkg.init()
@@ -95,6 +96,20 @@ class UtilsTest(DakTestCase):
self.assertEqual(parse_built_using(ctrl), expected)
self.assertEqual(parse_built_using({}), [])
+ def test_extract_component_from_section(self):
+ data = [
+ # Argument is passed through as first return value. There
+ # is a comment in docs/TODO.old suggesting that it should
+ # be changed.
+ ('utils', ('utils', 'main')),
+ ('main/utils', ('main/utils', 'main')),
+ ('non-free/libs', ('non-free/libs', 'non-free')),
+ ('contrib/net', ('contrib/net', 'contrib')),
+ ('non-free/two/slashes', ('non-free/two/slashes', 'non-free'))
+ ]
+ for v, r in data:
+ self.assertEqual(extract_component_from_section(v), r)
+
if __name__ == '__main__':
unittest.main()
--
2.1.4
Reply to: