mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-11 09:40:28 +03:00
test new common.regsub_file() method that replaces sed calls
This commit is contained in:
parent
85febd40d1
commit
64a9c93ce7
5 changed files with 815 additions and 0 deletions
|
|
@ -6,6 +6,7 @@
|
|||
import inspect
|
||||
import optparse
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
|
|
@ -17,6 +18,7 @@ if localmodule not in sys.path:
|
|||
sys.path.insert(0,localmodule)
|
||||
|
||||
import fdroidserver.common
|
||||
import fdroidserver.metadata
|
||||
|
||||
class CommonTest(unittest.TestCase):
|
||||
'''fdroidserver/common.py'''
|
||||
|
|
@ -95,6 +97,48 @@ class CommonTest(unittest.TestCase):
|
|||
self.assertFalse(fdroidserver.common.is_valid_package_name(name),
|
||||
"{0} should not be a valid package name".format(name))
|
||||
|
||||
def test_prepare_sources(self):
|
||||
testint = 99999999
|
||||
teststr = 'FAKE_STR_FOR_TESTING'
|
||||
testdir = os.path.dirname(__file__)
|
||||
|
||||
config = dict()
|
||||
config['sdk_path'] = os.getenv('ANDROID_HOME')
|
||||
config['build_tools'] = 'FAKE_BUILD_TOOLS_VERSION'
|
||||
fdroidserver.common.config = config
|
||||
app = dict()
|
||||
app['id'] = 'org.fdroid.froid'
|
||||
build = dict(fdroidserver.metadata.flag_defaults)
|
||||
build['commit'] = 'master'
|
||||
build['forceversion'] = True
|
||||
build['forcevercode'] = True
|
||||
build['gradle'] = ['yes']
|
||||
build['ndk_path'] = os.getenv('ANDROID_NDK_HOME')
|
||||
build['target'] = 'android-' + str(testint)
|
||||
build['type'] = 'gradle'
|
||||
build['version'] = teststr
|
||||
build['vercode'] = testint
|
||||
|
||||
class FakeVcs():
|
||||
# no need to change to the correct commit here
|
||||
def gotorevision(self, rev, refresh=True):
|
||||
pass
|
||||
|
||||
# no srclib info needed, but it could be added...
|
||||
def getsrclib(self):
|
||||
return None
|
||||
|
||||
fdroidserver.common.prepare_source(FakeVcs(), app, build, testdir, testdir, testdir)
|
||||
|
||||
filedata = open(os.path.join(testdir, 'build.gradle')).read()
|
||||
self.assertIsNotNone(re.search("\s+compileSdkVersion %s\s+" % testint, filedata))
|
||||
|
||||
filedata = open(os.path.join(testdir, 'AndroidManifest.xml')).read()
|
||||
self.assertIsNone(re.search('android:debuggable', filedata))
|
||||
self.assertIsNotNone(re.search('android:versionName="%s"' % build['version'], filedata))
|
||||
self.assertIsNotNone(re.search('android:versionCode="%s"' % build['vercode'], filedata))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue