Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[libcontentaction] Remove qt5-default dependency
Not required, qt4->5 build handling removed from other build
scripts a long time ago.
  • Loading branch information
blam committed Jun 30, 2020
1 parent 30c7ae8 commit 283061b
Show file tree
Hide file tree
Showing 20 changed files with 163 additions and 164 deletions.
6 changes: 3 additions & 3 deletions data/gen-regexps
@@ -1,4 +1,4 @@
#! /usr/bin/python
#! /usr/bin/python3
# coding=UTF-8

# This program generates the complicated regular expressions used in
Expand Down Expand Up @@ -49,8 +49,8 @@ def rx_opt (rx):
return rx_repeat (rx, 0, 1)

def rx_output (rx, name):
print("s/@%s@/%s/g\n" % (name,
rx.replace('\\', '\\\\').replace('/', '\\/').replace('"', '\"').replace('&', '\&')))
print(("s/@%s@/%s/g\n" % (name,
rx.replace('\\', '\\\\').replace('/', '\\/').replace('"', '\"').replace('&', '\&'))))

## Phone numbers

Expand Down
8 changes: 4 additions & 4 deletions data/regextest2.py
Expand Up @@ -4,7 +4,7 @@
import functools

#
# Note: unittest in python < 2.7 doesn't support expectedFailures
# Note: this was originally written with python2.7 unittest which doesn't support expectedFailures
#

def escape_for_shell (str):
Expand Down Expand Up @@ -32,8 +32,8 @@ def regex_test (self):
parts = self.__spec.split (self.__delimiter)
text = "".join (parts)
expected = [ parts[i] for i in range (1, len (parts), 2) ]
result = list (map (lambda m: m.group(0), re.finditer (self.__regex, text)))
self.assertEquals (result, expected)
result = list ([m.group(0) for m in re.finditer (self.__regex, text)])
self.assertEqual (result, expected)


class SystemRegexTest (unittest.TestCase):
Expand Down Expand Up @@ -83,7 +83,7 @@ def regex_test (self):

expected_result = expected.pop (0)

self.assertEquals (result[1:-1], expected_result,
self.assertEqual (result[1:-1], expected_result,
"'%s' is not recognized properly " % (self.__spec)
+ "(matched '%s' instead of '%s')" % (result,
expected_result)
Expand Down
9 changes: 4 additions & 5 deletions rpm/libcontentaction-qt5.spec
Expand Up @@ -15,7 +15,7 @@ BuildRequires: pkgconfig(Qt5Test)
BuildRequires: pkgconfig(Qt5Xml)
BuildRequires: pkgconfig(Qt5SystemInfo)
BuildRequires: pkgconfig(Qt5Qml)
BuildRequires: python
BuildRequires: python3-base
BuildRequires: qt5-qttools-linguist

%description
Expand All @@ -34,11 +34,10 @@ libcontentaction library.
%package tests
Summary: Tests for libcontentaction
Requires: %{name} = %{version}-%{release}
Requires: dbus-python
Requires: pygobject2
Requires: python
Requires: dbus-python3
Requires: python3-gobject
Requires: python3-base
Requires: tracker-utils
Requires: qt5-default
Requires: qt5-qttools-qdbus

%description tests
Expand Down
2 changes: 1 addition & 1 deletion tests/applications/fixedparams.desktop
Expand Up @@ -5,7 +5,7 @@ GenericName=Launch Me
Comment=Test helper
X-Maemo-Service=just.a.gallery
X-Maemo-Method=com.nokia.galleryserviceinterface.showImage
Exec=python -c "f = open('/tmp/actionParams', 'w'); f.write('The params are %U');"
Exec=python3 -c "f = open('/tmp/actionParams', 'w'); f.write('The params are %U');"
X-Maemo-Fixed-Args=these;are;fixed
Terminal=false
MimeType=text/*;
Expand Down
2 changes: 1 addition & 1 deletion tests/applications/uberexec.desktop
Expand Up @@ -6,7 +6,7 @@ Name[de]=deutschexec
GenericName=Uber Program
Icon=execicon
Comment=View ANYTHING
Exec=python -c "f = open(%U); content=f.read(); f2 = open('/tmp/executedAction', 'w'); f2.write(content);"
Exec=python3 -c "f = open(%U); content=f.read(); f2 = open('/tmp/executedAction', 'w'); f2.write(content);"
Terminal=false
Type=Application
MimeType=text/plain;
Expand Down
2 changes: 1 addition & 1 deletion tests/applications/uriprinter.desktop
Expand Up @@ -2,7 +2,7 @@
Encoding=UTF-8
Name=UriPrinter
Comment=Just prints the params into a file
Exec=python -c "f2 = open('/tmp/executedAction', 'w'); f2.write(\\"%U\\n\\");"
Exec=python3 -c "f2 = open('/tmp/executedAction', 'w'); f2.write(\\"%U\\n\\");"
Terminal=false
Type=Application
MimeType=image/png;
Expand Down
16 changes: 8 additions & 8 deletions tests/cltool.py
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
##
## Copyright (C) 2009 Nokia. All rights reserved.
##
Expand All @@ -18,7 +18,7 @@
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
## 02110-1301 USA

from __future__ import with_statement


import os
import re
Expand Down Expand Up @@ -99,7 +99,7 @@ def send(self, string):
with self.iolock:
self.io.append((time.time(), CLTool.STDIN, string))
try:
print >>self.process.stdin, string
print(string, file=self.process.stdin)
self.process.stdin.flush()
except:
self.printio()
Expand All @@ -115,7 +115,7 @@ def _last_output(self):
"""Compute the output read since the last match."""
r = []
with self.iolock:
for pos in xrange(self.last_expect, len(self.io)):
for pos in range(self.last_expect, len(self.io)):
ts, fno, l = self.io[pos]
if fno == CLTool.STDOUT:
r.append(l)
Expand Down Expand Up @@ -193,8 +193,8 @@ def wait(self):

def printio(self):
"""Dump the io log to the standard output."""
print
print '-' * 72
print()
print('-' * 72)
with self.iolock:
for ts, fno, line in self.io:
line = line.rstrip("\r\n")
Expand All @@ -203,8 +203,8 @@ def printio(self):
if fno == CLTool.COMMENT: info = "###";
if fno == CLTool.STDIN: info = "<--";
if fno == CLTool.STDOUT: info = "-->";
print "%s %s %s" % (t, info, line)
print '-' * 72
print("%s %s %s" % (t, info, line))
print('-' * 72)
sys.stdout.flush()

def wanted(name, type, value):
Expand Down
6 changes: 3 additions & 3 deletions tests/gallery.py
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
import dbus, dbus.service, dbus.mainloop.glib
from gi.repository import GObject as gobject
from sys import stdout, argv
Expand All @@ -11,11 +11,11 @@ def __init__(self, path, busname):
@dbus.service.method(dbus_interface='com.nokia.galleryserviceinterface',
in_signature='as', out_signature='b')
def showImage(self, uris):
print 'showImage ; %s' % (','.join(uris))
print('showImage ; %s' % (','.join(uris)))
stdout.flush()
return True

print "started"
print("started")
stdout.flush()
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
# if there is a command line parameter, use it as bus name (otherwise, use the
Expand Down
2 changes: 1 addition & 1 deletion tests/launchme.desktop
Expand Up @@ -3,7 +3,7 @@ Encoding=UTF-8
Name=launchme
GenericName=Launch Me
Comment=Test helper
Exec=python -c "f = open('/tmp/launchedAction', 'w'); f.write('I was launched');"
Exec=python3 -c "f = open('/tmp/launchedAction', 'w'); f.write('I was launched');"
Terminal=false
Type=Application

10 changes: 5 additions & 5 deletions tests/servicemapper.py
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
import os
import dbus, dbus.service, dbus.mainloop.glib
from gi.repository import GObject as gobject
Expand All @@ -10,9 +10,9 @@ def __init__(self, path):
dbus.SessionBus())
self.mapping = {}
try:
execfile('service.map')
exec(compile(open('service.map', "rb").read(), 'service.map', 'exec'))
except IOError:
execfile(os.path.dirname(__file__) + '/service.map')
exec(compile(open(os.path.dirname(__file__) + '/service.map', "rb").read(), os.path.dirname(__file__) + '/service.map', 'exec'))

@dbus.service.method(dbus_interface='com.nokia.MServiceFwIf',
in_signature='s', out_signature='s')
Expand All @@ -37,12 +37,12 @@ def emitServiceUnavailable(self, implementor):
@dbus.service.signal(dbus_interface='com.nokia.MServiceFwIf',
signature='ss')
def serviceAvailable(self, implementor, interface):
print "emit service available", implementor, interface
print("emit service available", implementor, interface)

@dbus.service.signal(dbus_interface='com.nokia.MServiceFwIf',
signature='s')
def serviceUnavailable(self, implementor):
print "emit service unavailable", implementor
print("emit service unavailable", implementor)

dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
napper = ServiceMapper('/')
Expand Down
28 changes: 14 additions & 14 deletions tests/test-defaults.py
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
##
## Copyright (C) 2008, 2009 Nokia. All rights reserved.
##
Expand Down Expand Up @@ -27,7 +27,7 @@
except: pass

import unittest
from commands import getstatusoutput
from subprocess import getstatusoutput
from cltool import CLTool
from tempfile import mkdtemp
from shutil import rmtree
Expand All @@ -42,35 +42,35 @@ def tearDown(self):

def testSettingDefault(self):
(status, output) = getstatusoutput("lca-tool --setmimedefault text/plain ubermeego")
self.assert_(status == 0)
self.assertTrue(status == 0)

(status, output) = getstatusoutput("lca-tool --mimedefault text/plain")
self.assert_(status == 0)
self.assert_(output.find("ubermeego") != -1)
self.assertTrue(status == 0)
self.assertTrue(output.find("ubermeego") != -1)

def testDefaultIsFirst(self):
(status, output) = getstatusoutput("lca-tool --setmimedefault text/plain uberexec")
self.assert_(status == 0)
self.assertTrue(status == 0)
(status, output) = getstatusoutput("lca-tool --actionsformime text/plain")

self.assert_(status == 0)
self.assert_(output.find("uberexec") < output.find("ubermeego"))
self.assert_(output.find("uberexec") < output.find("ubermimeopen"))
self.assertTrue(status == 0)
self.assertTrue(output.find("uberexec") < output.find("ubermeego"))
self.assertTrue(output.find("uberexec") < output.find("ubermimeopen"))

def testResettingDefault(self):
# check what are the actions (in order) before
(status, oldactions) = getstatusoutput("lca-tool --actionsformime text/plain")
self.assert_(status == 0)
self.assertTrue(status == 0)

(status, output) = getstatusoutput("lca-tool --setmimedefault text/plain ubermeego")
self.assert_(status == 0)
self.assertTrue(status == 0)

(status, output) = getstatusoutput("lca-tool --resetmimedefault text/plain")
self.assert_(status == 0)
self.assertTrue(status == 0)

(status, newactions) = getstatusoutput("lca-tool --actionsformime text/plain")
self.assert_(status == 0)
self.assert_(newactions == oldactions)
self.assertTrue(status == 0)
self.assertTrue(newactions == oldactions)

def runTests():
suite = unittest.TestLoader().loadTestsFromTestCase(Defaults)
Expand Down
16 changes: 8 additions & 8 deletions tests/test-desktop-launching.py
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
##
## Copyright (C) 2010 Nokia. All rights reserved.
##
Expand Down Expand Up @@ -27,7 +27,7 @@
except: pass

import unittest
from commands import getstatusoutput
from subprocess import getstatusoutput
from cltool import CLTool
import time

Expand All @@ -40,29 +40,29 @@ class Launching(unittest.TestCase):
def testActionsForDesktop(self):
filename = "file://" + testfiles_dir + "/launchme.desktop"
(status, output) = getstatusoutput("lca-tool --file --print " + filename)
self.assert_(status == 0)
self.assert_(output.find("launchme") != -1)
self.assertTrue(status == 0)
self.assertTrue(output.find("launchme") != -1)

def testLaunch(self):
filename = "file://" + testfiles_dir + "/launchme.desktop"
(status, output) = getstatusoutput("lca-tool --file --triggerdefault " + filename)
self.assert_(status == 0)
self.assertTrue(status == 0)

time.sleep(3)
f = open('/tmp/launchedAction')
content = f.read()
f.close()
os.remove("/tmp/launchedAction")
self.assert_(content.find("I was launched") != -1)
self.assertTrue(content.find("I was launched") != -1)

def testLaunchWithParams(self):
(status, output) = getstatusoutput("lca-tool --triggerdesktop uriprinter.desktop param1 param2 param3")
f = open("/tmp/executedAction")
content = f.read()
f.close()
os.remove("/tmp/executedAction")
self.assert_(status == 0)
self.assert_(content.find("'param1' 'param2' 'param3'") != -1)
self.assertTrue(status == 0)
self.assertTrue(content.find("'param1' 'param2' 'param3'") != -1)

def runTests():
suite = unittest.TestLoader().loadTestsFromTestCase(Launching)
Expand Down
10 changes: 5 additions & 5 deletions tests/test-fixed-params.py
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
##
## Copyright (C) 2010 Nokia. All rights reserved.
##
Expand Down Expand Up @@ -27,7 +27,7 @@
except: pass

import unittest
from commands import getstatusoutput
from subprocess import getstatusoutput
from cltool import CLTool

# this controls where the test files are
Expand All @@ -39,17 +39,17 @@ class FixedParams(unittest.TestCase):
def setUp(self):
# start a fake gallery service
self.gallery = CLTool("gallery.py")
self.assert_(self.gallery.expect("started"))
self.assertTrue(self.gallery.expect("started"))

def tearDown(self):
self.gallery.kill()

def testInvokeWithFixedParams(self):
filename = "file://" + testfiles_dir + "/plaintext"
(status, output) = getstatusoutput("lca-tool --file --trigger fixedparams " + filename)
self.assert_(status == 0)
self.assertTrue(status == 0)
# assert that the gallery was invoked and the fixed params got prepended
self.assert_(self.gallery.expect("showImage ; these,are,fixed," + filename))
self.assertTrue(self.gallery.expect("showImage ; these,are,fixed," + filename))

def runTests():
suite = unittest.TestLoader().loadTestsFromTestCase(FixedParams)
Expand Down
12 changes: 6 additions & 6 deletions tests/test-invalid-defaults.py
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
##
## Copyright (C) 2008, 2009 Nokia. All rights reserved.
##
Expand Down Expand Up @@ -27,7 +27,7 @@
except: pass

import unittest
from commands import getstatusoutput
from subprocess import getstatusoutput
from cltool import CLTool

# this controls where the test files are
Expand All @@ -40,14 +40,14 @@ def testInvalidDefaultForUri(self):
# this uri is a ncal:Event, and x-maemo-nepomuk/calendar-event has a
# mimeapps.list entry pointing to a nonexistent application.
(status, output) = getstatusoutput("lca-tool --tracker --printdefault urn:test:calendarevent")
self.assert_(status == 0)
self.assert_(output.find("Invalid action") != -1)
self.assertTrue(status == 0)
self.assertTrue(output.find("Invalid action") != -1)

def testInvalidDefaultForFile(self):
filename = "file://" + testfiles_dir + "/empty.pdf"
(status, output) = getstatusoutput("lca-tool --file --printdefault " + filename)
self.assert_(status == 0)
self.assert_(output.find("Invalid action") != -1)
self.assertTrue(status == 0)
self.assertTrue(output.find("Invalid action") != -1)

def runTests():
suite = unittest.TestLoader().loadTestsFromTestCase(InvalidDefaults)
Expand Down

0 comments on commit 283061b

Please sign in to comment.