mirror of
				https://github.com/f-droid/fdroidserver.git
				synced 2025-11-04 06:30:27 +03:00 
			
		
		
		
	add test files to pre-commit hook and fix pep8 errors
This commit is contained in:
		
							parent
							
								
									84c9777e9e
								
							
						
					
					
						commit
						9e5dd19fc8
					
				
					 4 changed files with 20 additions and 19 deletions
				
			
		| 
						 | 
				
			
			@ -6,7 +6,7 @@
 | 
			
		|||
# Redirect output to stderr.
 | 
			
		||||
exec 1>&2
 | 
			
		||||
 | 
			
		||||
PY_FILES="fdroid makebuildserver setup.py examples/*.py buildserver/*.py fdroidserver/*.py"
 | 
			
		||||
PY_FILES="fdroid makebuildserver setup.py examples/*.py buildserver/*.py fdroidserver/*.py tests/*.TestCase"
 | 
			
		||||
SH_FILES="hooks/pre-commit"
 | 
			
		||||
BASH_FILES="fd-commit jenkins-build docs/update.sh completion/bash-completion"
 | 
			
		||||
RB_FILES="buildserver/cookbooks/*/recipes/*.rb"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,16 +12,16 @@ import sys
 | 
			
		|||
import tempfile
 | 
			
		||||
import unittest
 | 
			
		||||
 | 
			
		||||
localmodule = os.path.realpath(os.path.join(
 | 
			
		||||
        os.path.dirname(inspect.getfile(inspect.currentframe())),
 | 
			
		||||
        '..'))
 | 
			
		||||
localmodule = os.path.realpath(
 | 
			
		||||
    os.path.join(os.path.dirname(inspect.getfile(inspect.currentframe())), '..'))
 | 
			
		||||
print('localmodule: ' + localmodule)
 | 
			
		||||
if localmodule not in sys.path:
 | 
			
		||||
    sys.path.insert(0,localmodule)
 | 
			
		||||
    sys.path.insert(0, localmodule)
 | 
			
		||||
 | 
			
		||||
import fdroidserver.common
 | 
			
		||||
import fdroidserver.metadata
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CommonTest(unittest.TestCase):
 | 
			
		||||
    '''fdroidserver/common.py'''
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -50,7 +50,7 @@ class CommonTest(unittest.TestCase):
 | 
			
		|||
    def test_find_sdk_tools_cmd(self):
 | 
			
		||||
        fdroidserver.common.config = dict()
 | 
			
		||||
        # TODO add this once everything works without sdk_path set in config
 | 
			
		||||
        #self._find_all()
 | 
			
		||||
        # self._find_all()
 | 
			
		||||
        sdk_path = os.getenv('ANDROID_HOME')
 | 
			
		||||
        if os.path.exists(sdk_path):
 | 
			
		||||
            fdroidserver.common.config['sdk_path'] = sdk_path
 | 
			
		||||
| 
						 | 
				
			
			@ -67,7 +67,7 @@ class CommonTest(unittest.TestCase):
 | 
			
		|||
        config = dict()
 | 
			
		||||
        config['sdk_path'] = os.getenv('ANDROID_HOME')
 | 
			
		||||
        fdroidserver.common.config = config
 | 
			
		||||
        self._set_build_tools();
 | 
			
		||||
        self._set_build_tools()
 | 
			
		||||
        config['aapt'] = fdroidserver.common.find_sdk_tools_cmd('aapt')
 | 
			
		||||
        # these are set debuggable
 | 
			
		||||
        testfiles = []
 | 
			
		||||
| 
						 | 
				
			
			@ -91,13 +91,13 @@ class CommonTest(unittest.TestCase):
 | 
			
		|||
        for name in ["org.fdroid.fdroid",
 | 
			
		||||
                     "org.f_droid.fdr0ID"]:
 | 
			
		||||
            self.assertTrue(fdroidserver.common.is_valid_package_name(name),
 | 
			
		||||
                    "{0} should be a valid package name".format(name))
 | 
			
		||||
                            "{0} should be a valid package name".format(name))
 | 
			
		||||
        for name in ["0rg.fdroid.fdroid",
 | 
			
		||||
                     ".f_droid.fdr0ID",
 | 
			
		||||
                     "org.fdroid/fdroid",
 | 
			
		||||
                     "/org.fdroid.fdroid"]:
 | 
			
		||||
            self.assertFalse(fdroidserver.common.is_valid_package_name(name),
 | 
			
		||||
                    "{0} should not be a valid package name".format(name))
 | 
			
		||||
                             "{0} should not be a valid package name".format(name))
 | 
			
		||||
 | 
			
		||||
    def test_prepare_sources(self):
 | 
			
		||||
        testint = 99999999
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,16 +9,16 @@ import os
 | 
			
		|||
import sys
 | 
			
		||||
import unittest
 | 
			
		||||
 | 
			
		||||
localmodule = os.path.realpath(os.path.join(
 | 
			
		||||
        os.path.dirname(inspect.getfile(inspect.currentframe())),
 | 
			
		||||
        '..'))
 | 
			
		||||
localmodule = os.path.realpath(
 | 
			
		||||
    os.path.join(os.path.dirname(inspect.getfile(inspect.currentframe())), '..'))
 | 
			
		||||
print('localmodule: ' + localmodule)
 | 
			
		||||
if localmodule not in sys.path:
 | 
			
		||||
    sys.path.insert(0,localmodule)
 | 
			
		||||
    sys.path.insert(0, localmodule)
 | 
			
		||||
 | 
			
		||||
import fdroidserver.common
 | 
			
		||||
import fdroidserver.install
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class InstallTest(unittest.TestCase):
 | 
			
		||||
    '''fdroidserver/install.py'''
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,22 +4,23 @@
 | 
			
		|||
# http://www.drdobbs.com/testing/unit-testing-with-python/240165163
 | 
			
		||||
 | 
			
		||||
import inspect
 | 
			
		||||
import logging
 | 
			
		||||
import optparse
 | 
			
		||||
import os
 | 
			
		||||
import sys
 | 
			
		||||
import unittest
 | 
			
		||||
 | 
			
		||||
localmodule = os.path.realpath(os.path.join(
 | 
			
		||||
        os.path.dirname(inspect.getfile(inspect.currentframe())),
 | 
			
		||||
        '..'))
 | 
			
		||||
localmodule = os.path.realpath(
 | 
			
		||||
    os.path.join(os.path.dirname(inspect.getfile(inspect.currentframe())), '..'))
 | 
			
		||||
print('localmodule: ' + localmodule)
 | 
			
		||||
if localmodule not in sys.path:
 | 
			
		||||
    sys.path.insert(0,localmodule)
 | 
			
		||||
    sys.path.insert(0, localmodule)
 | 
			
		||||
 | 
			
		||||
import fdroidserver.common
 | 
			
		||||
import fdroidserver.update
 | 
			
		||||
from fdroidserver.common import FDroidPopen
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class UpdateTest(unittest.TestCase):
 | 
			
		||||
    '''fdroid update'''
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -39,13 +40,13 @@ class UpdateTest(unittest.TestCase):
 | 
			
		|||
            return sig
 | 
			
		||||
        else:
 | 
			
		||||
            return None
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
    def testGoodGetsig(self):
 | 
			
		||||
        apkfile = os.path.join(os.path.dirname(__file__), 'urzip.apk')
 | 
			
		||||
        sig = self.javagetsig(apkfile)
 | 
			
		||||
        self.assertIsNotNone(sig, "sig is None")
 | 
			
		||||
        pysig = fdroidserver.update.getsig(apkfile)
 | 
			
		||||
        self.assertIsNotNone(pysig, "pysig is None")        
 | 
			
		||||
        self.assertIsNotNone(pysig, "pysig is None")
 | 
			
		||||
        self.assertEquals(sig, fdroidserver.update.getsig(apkfile),
 | 
			
		||||
                          "python sig not equal to java sig!")
 | 
			
		||||
        self.assertEquals(len(sig), len(pysig),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue