Commit 8700a2e1 authored by Chris Lamb's avatar Chris Lamb 💬

Revert "Revert "Add some tests for APK comarator." - accidental commit."

This reverts commit 5db4939f.

Gbp-Dch: Ignore
parent 5db4939f
# -*- coding: utf-8 -*-
#
# diffoscope: in-depth comparison of files, archives, and directories
#
# Copyright © 2017 Maria Glukhova <siammezzze@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
@pytest.fixture
def differences(apk1, apk2):
return apk1.compare(apk2).details
@skip_unless_tools_exist('apktool', 'zipinfo')
def test_compare_non_existing(monkeypatch, apk1):
assert_non_existing(monkeypatch, apk1)
@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
@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
@skip_unless_tools_exist('apktool', 'zipinfo')
def test_apk_metadata_source(differences):
assert differences[2].source1 == 'APK metadata'
assert differences[2].source2 == 'APK metadata'
@@ -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>
@@ -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%
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment