[diffoscope] 01/04: Revert "Revert "Add some tests for APK comarator." - accidental commit."

Chris Lamb chris at chris-lamb.co.uk
Sun Jan 15 03:46:56 CET 2017


This is an automated email from the git hooks/post-receive script.

lamby pushed a commit to branch master
in repository diffoscope.

commit 8700a2e1cf76a5ba84c964cdd6cc65b15441e152
Author: Chris Lamb <lamby at debian.org>
Date:   Sun Jan 15 13:07:13 2017 +1100

    Revert "Revert "Add some tests for APK comarator." - accidental commit."
    
    This reverts commit 5db4939f952246b4597c04df44684d143678af10.
    
    Gbp-Dch: Ignore
---
 tests/comparators/test_apk.py         |  62 ++++++++++++++++++++++++++++++++++
 tests/data/apk_manifest_expected_diff |  11 ++++++
 tests/data/apk_zipinfo_expected_diff  |   6 ++++
 tests/data/test1.apk                  | Bin 0 -> 866 bytes
 tests/data/test2.apk                  | Bin 0 -> 864 bytes
 5 files changed, 79 insertions(+)

diff --git a/tests/comparators/test_apk.py b/tests/comparators/test_apk.py
new file mode 100644
index 0000000..6253ace
--- /dev/null
+++ b/tests/comparators/test_apk.py
@@ -0,0 +1,62 @@
+# -*- coding: utf-8 -*-
+#
+# diffoscope: in-depth comparison of files, archives, and directories
+#
+# Copyright © 2017 Maria Glukhova <siammezzze at gmail.com>
+#
+# diffoscope is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# diffoscope is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with diffoscope.  If not, see <https://www.gnu.org/licenses/>.
+
+import pytest
+
+from diffoscope.comparators.apk import ApkFile
+
+from utils import skip_unless_tools_exist, data, load_fixture, \
+    assert_non_existing
+
+apk1 = load_fixture(data('test1.apk'))
+apk2 = load_fixture(data('test2.apk'))
+
+def test_identification(apk1):
+    assert isinstance(apk1, ApkFile)
+
+def test_no_differences(apk1):
+    difference = apk1.compare(apk1)
+    assert difference is None
+
+ at pytest.fixture
+def differences(apk1, apk2):
+    return apk1.compare(apk2).details
+
+ at skip_unless_tools_exist('apktool', 'zipinfo')
+def test_compare_non_existing(monkeypatch, apk1):
+    assert_non_existing(monkeypatch, apk1)
+
+ at skip_unless_tools_exist('apktool', 'zipinfo')
+def test_zipinfo(differences):
+    assert differences[0].source1 == 'zipinfo {}'
+    assert differences[0].source2 == 'zipinfo {}'
+    expected_diff = open(data('apk_zipinfo_expected_diff')).read()
+    assert differences[0].unified_diff == expected_diff
+
+ at skip_unless_tools_exist('apktool', 'zipinfo')
+def test_android_manifest(differences):
+    assert differences[1].source1 == 'AndroidManifest.xml'
+    assert differences[1].source2 == 'AndroidManifest.xml'
+    expected_diff = open(data('apk_manifest_expected_diff')).read()
+    assert differences[1].unified_diff == expected_diff
+
+ at skip_unless_tools_exist('apktool', 'zipinfo')
+def test_apk_metadata_source(differences):
+    assert differences[2].source1 == 'APK metadata'
+    assert differences[2].source2 == 'APK metadata'
diff --git a/tests/data/apk_manifest_expected_diff b/tests/data/apk_manifest_expected_diff
new file mode 100644
index 0000000..9d37a92
--- /dev/null
+++ b/tests/data/apk_manifest_expected_diff
@@ -0,0 +1,11 @@
+@@ -1,9 +1,9 @@
+ <?xml version="1.0" encoding="utf-8"?>
+-<manifest android:versionCode="1" android:versionName="1.0" package="com.any.any" platformBuildVersionCode="24" platformBuildVersionName="7.0.0"
++<manifest android:versionCode="2" android:versionName="2.0" package="com.any.any" platformBuildVersionCode="24" platformBuildVersionName="7.0.0"
+   xmlns:android="http://schemas.android.com/apk/res/android">
+     <uses-permission android:name="android.permission.INTERNET" />
+     <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
+     <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+     <application>
+         <activity android:name="com.any.any.SomeActivity">
+             <intent-filter>
diff --git a/tests/data/apk_zipinfo_expected_diff b/tests/data/apk_zipinfo_expected_diff
new file mode 100644
index 0000000..d1810dc
--- /dev/null
+++ b/tests/data/apk_zipinfo_expected_diff
@@ -0,0 +1,6 @@
+@@ -1,3 +1,3 @@
+-Zip file size: 866 bytes, number of entries: 1
++Zip file size: 864 bytes, number of entries: 1
+ -rw----     2.0 fat     2096 bl defN 80-Jan-01 02:00 AndroidManifest.xml
+-1 file, 2096 bytes uncompressed, 714 bytes compressed:  65.9%
++1 file, 2096 bytes uncompressed, 712 bytes compressed:  66.0%
diff --git a/tests/data/test1.apk b/tests/data/test1.apk
new file mode 100644
index 0000000..45876d6
Binary files /dev/null and b/tests/data/test1.apk differ
diff --git a/tests/data/test2.apk b/tests/data/test2.apk
new file mode 100644
index 0000000..925fb42
Binary files /dev/null and b/tests/data/test2.apk differ

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list