diff options
Diffstat (limited to 'tests/test_android.py')
| -rw-r--r-- | tests/test_android.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/test_android.py b/tests/test_android.py new file mode 100644 index 0000000..a72f8d8 --- /dev/null +++ b/tests/test_android.py | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | import os | ||
| 2 | |||
| 3 | from karton.android import Android | ||
| 4 | |||
| 5 | from karton.core import Task | ||
| 6 | from karton.core.test import KartonTestCase, TestResource | ||
| 7 | |||
| 8 | |||
| 9 | class AndroidMagicTestCase(KartonTestCase): | ||
| 10 | karton_class = Android | ||
| 11 | |||
| 12 | def test_android(self): | ||
| 13 | testcase = os.path.join(os.path.dirname(__file__), "testsdata", "example.apk") | ||
| 14 | with self.subTest(testcase): | ||
| 15 | with open(testcase, "rb") as f: | ||
| 16 | content = f.read() | ||
| 17 | sample = TestResource(testcase, content) | ||
| 18 | expected = Task( | ||
| 19 | { | ||
| 20 | "type": "sample", | ||
| 21 | "stage": "analyzed", | ||
| 22 | "origin": "karton.android", | ||
| 23 | }, | ||
| 24 | payload={ | ||
| 25 | 'attributes': { | ||
| 26 | "certificate": ["61ED377E85D386A8DFEE6B864BD85B0BFAA5AF81"], | ||
| 27 | "main_activity": ["com.example.android.contactmanager..ContactManager"], | ||
| 28 | "package": ["com.example.android.contactmanager"], | ||
| 29 | "activities": ["com.example.android.contactmanager..ContactManager", "com.example.android.contactmanager.ContactAdder"], | ||
| 30 | "permissions": ["android.permission.GET_ACCOUNTS", "android.permission.READ_CONTACTS", "android.permission.WRITE_CONTACTS"], | ||
| 31 | } | ||
| 32 | }, | ||
| 33 | ) | ||
| 34 | task = Task( | ||
| 35 | { | ||
| 36 | "type": "sample", | ||
| 37 | "extension": "apk", | ||
| 38 | }, | ||
| 39 | payload={"sample": sample}, | ||
| 40 | ) | ||
| 41 | results = self.run_task(task) | ||
| 42 | |||
| 43 | self.assertTasksEqual(results, [expected]) | ||
