forked from MicroPythonOS/MicroPythonOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_package_manager.py
More file actions
50 lines (34 loc) · 1.85 KB
/
test_package_manager.py
File metadata and controls
50 lines (34 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import unittest
from mpos import App, AppManager
class TestCompareVersions(unittest.TestCase):
def test_lower_short(self):
self.assertFalse(AppManager.compare_versions("1" , "4"))
def test_lower(self):
self.assertFalse(AppManager.compare_versions("1.2.3" , "4.5.6"))
def test_equal(self):
self.assertFalse(AppManager.compare_versions("1.2.3" , "1.2.3"))
def test_higher(self):
self.assertTrue(AppManager.compare_versions("4.5.6", "1.2.3"))
def test_higher_medium_and_long(self):
self.assertTrue(AppManager.compare_versions("4.5", "1.2.3"))
def test_words(self):
self.assertFalse(AppManager.compare_versions("weird" , "input"))
def test_one_empty(self):
self.assertFalse(AppManager.compare_versions("1.2.3" , ""))
class TestAppManager_is_installed_by_name(unittest.TestCase):
def test_installed_builtin(self):
self.assertTrue(AppManager.is_installed_by_name("com.micropythonos.appstore"))
def test_installed_not_builtin(self):
self.assertTrue(AppManager.is_installed_by_name("com.micropythonos.helloworld"))
def test_not_installed(self):
self.assertFalse(AppManager.is_installed_by_name("com.micropythonos.badname"))
class TestAppManager_get_app_list(unittest.TestCase):
def test_get_app_list(self):
app_list = AppManager.get_app_list()
self.assertGreaterEqual(len(app_list), 13) # more if the symlinks in internal_filesystem/app aren't dangling
def test_get_app(self):
app_list = AppManager.get_app_list()
hello_world_app = AppManager.get("com.micropythonos.helloworld")
self.assertIsInstance(hello_world_app, App)
self.assertEqual(hello_world_app.icon_path, "apps/com.micropythonos.helloworld/res/mipmap-mdpi/icon_64x64.png")
self.assertEqual(len(hello_world_app.icon_data), 5499)