Skip to content

Commit 295536e

Browse files
committed
Add tests for picard.util.versions
1 parent 547edb3 commit 295536e

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

test/test_util_versions.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Picard, the next-generation MusicBrainz tagger
4+
#
5+
# Copyright (C) 2025 Philipp Wolfer
6+
#
7+
# This program is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License
9+
# as published by the Free Software Foundation; either version 2
10+
# of the License, or (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program; if not, write to the Free Software
19+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20+
21+
22+
from unittest import TestCase
23+
24+
from picard import PICARD_FANCY_VERSION_STR
25+
from picard.util.versions import (
26+
_names,
27+
as_dict,
28+
as_string,
29+
version_name,
30+
)
31+
32+
33+
class UtilVersionsTest(TestCase):
34+
35+
def test_version_name(self):
36+
self.assertEqual(version_name('version'), 'Picard')
37+
self.assertEqual(version_name('python-version'), 'Python')
38+
39+
def test_as_dict(self):
40+
versions = as_dict()
41+
self.assertIsInstance(versions, dict)
42+
self.assertEqual(versions['version'], PICARD_FANCY_VERSION_STR)
43+
for name in _names:
44+
self.assertIn(name, versions)
45+
46+
def test_as_string(self):
47+
versions = as_string()
48+
self.assertIsInstance(versions, str)
49+
self.assertTrue(versions.startswith(f'Picard {PICARD_FANCY_VERSION_STR}, Python '))
50+
for name in _names.values():
51+
self.assertIn(name, versions)
52+
53+
def test_as_string_with_separator(self):
54+
versions = as_string(separator='/')
55+
self.assertIsInstance(versions, str)
56+
self.assertTrue(versions.startswith(f'Picard {PICARD_FANCY_VERSION_STR}/Python '))

0 commit comments

Comments
 (0)