diff --git a/.gitignore b/.gitignore index aff00e76..b2f5263c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ **pyc -**dat +#**dat **.DS_Store src/build src/dist @@ -21,4 +21,4 @@ build pyan/ .buildozer/ bin/ -src/images/kivy/default_identicon/*.png \ No newline at end of file +src/images/kivy/default_identicon/*.png diff --git a/.travis-kivy.yml b/.travis-kivy.yml new file mode 100644 index 00000000..d3b10889 --- /dev/null +++ b/.travis-kivy.yml @@ -0,0 +1,15 @@ +language: python3.7 +cache: pip3 +dist: bionic +python: + - "3.7" +addons: + apt: + packages: + - build-essential + - libcap-dev + - xvfb +install: + - pip3 install -r kivy-requirements.txt +script: + - xvfb-run python3 -m unittest src/bitmessagekivy/tests/test_create_random_address.py diff --git a/Dockerfile.kivy-travis b/Dockerfile.kivy-travis new file mode 100644 index 00000000..f0391add --- /dev/null +++ b/Dockerfile.kivy-travis @@ -0,0 +1,63 @@ +FROM ubuntu:bionic AS pybm-kivy-travis-bionic + +ENV DEBIAN_FRONTEND noninteractive +ENV TRAVIS_SKIP_APT_UPDATE 1 + +RUN apt-get update + +RUN apt-get install -yq --no-install-suggests --no-install-recommends \ + software-properties-common + +RUN dpkg --add-architecture i386 + +RUN add-apt-repository ppa:deadsnakes/ppa + +RUN apt-get -y install sudo + +RUN apt-get -y install git + +RUN apt-get install -yq --no-install-suggests --no-install-recommends \ + # travis xenial bionic + python-setuptools libssl-dev libpq-dev python-prctl python-dev \ + python-dev python-virtualenv python-pip virtualenv \ + # Code quality + pylint python-pycodestyle python3-pycodestyle pycodestyle python-flake8 \ + python3-flake8 flake8 python-pyflakes python3-pyflakes pyflakes pyflakes3 \ + curl \ + # Wine + python python-pip wget wine-stable winetricks mingw-w64 wine32 wine64 xvfb \ + # Buildbot + python3-dev libffi-dev python3-setuptools \ + python3-pip \ + # python 3.7 + python3.7 python3.7-dev \ + # .travis.yml + build-essential libcap-dev tor \ + language-pack-en + +# cleanup +RUN rm -rf /var/lib/apt/lists/* + +RUN useradd -m -U builder + +RUN echo 'builder ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers + +# travis2bash +RUN wget -O /usr/local/bin/travis2bash.sh https://git.bitmessage.org/Bitmessage/buildbot-scripts/raw/branch/master/travis2bash.sh +RUN chmod +x /usr/local/bin/travis2bash.sh + +# copy sources +COPY . /home/builder/src +RUN chown -R builder.builder /home/builder/src + +USER builder + +ENV LANG en_US.UTF-8 +ENV LANGUAGE en_US:en +ENV LC_ALL en_US.UTF-8 + +WORKDIR /home/builder/src + + +# ENTRYPOINT /usr/local/bin/travis2bash.sh +ENTRYPOINT ["/usr/local/bin/travis2bash.sh", ".travis-kivy.yml"] diff --git a/python3_requirements.txt b/python3_requirements.txt index 6276704e..5c2497cd 100644 --- a/python3_requirements.txt +++ b/python3_requirements.txt @@ -29,4 +29,6 @@ six==1.12.0 typed-ast==1.4.0 urllib3==1.25.6 wrapt==1.11.2 -zipp==3.1.0 \ No newline at end of file +zipp==3.1.0 +xclip +xsel \ No newline at end of file diff --git a/run-kivy-tests-in-docker.sh b/run-kivy-tests-in-docker.sh new file mode 100755 index 00000000..1308aac2 --- /dev/null +++ b/run-kivy-tests-in-docker.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +docker build -t pybm-kivy-travis-bionic -f Dockerfile.kivy-travis . +docker run pybm-kivy-travis-bionic diff --git a/src/bitmessagekivy/baseclass/msg_composer.py b/src/bitmessagekivy/baseclass/msg_composer.py index fc8e1b39..6ad1cef6 100644 --- a/src/bitmessagekivy/baseclass/msg_composer.py +++ b/src/bitmessagekivy/baseclass/msg_composer.py @@ -27,7 +27,7 @@ from kivy.uix.textinput import TextInput import state import queues -from addresses import decodeAddress +from addresses import decodeAddress, addBMIfNotPresent from bitmessagekivy.baseclass.common import ( toast, showLimitedCnt ) @@ -110,7 +110,6 @@ class DropDownWidget(BoxLayout): # state.detailPageType = '' # state.send_draft_mail = None else: - from addresses import addBMIfNotPresent # toAddress = addBMIfNotPresent(toAddress) if (addressVersionNumber > 4) or ( addressVersionNumber <= 1): diff --git a/src/bitmessagekivy/tests/sampleData/keys.dat b/src/bitmessagekivy/tests/sampleData/keys.dat new file mode 100644 index 00000000..940b3e14 --- /dev/null +++ b/src/bitmessagekivy/tests/sampleData/keys.dat @@ -0,0 +1,59 @@ +[bitmessagesettings] +settingsversion = 0 +port = 8444 +timeformat = %%c +blackwhitelist = black +startonlogon = false +minimizetotray = false +showtraynotifications = true +startintray = false +socksproxytype = none +sockshostname = localhost +socksport = 9050 +socksauthentication = false +socksusername = +sockspassword = +keysencrypted = false +messagesencrypted = false +defaultnoncetrialsperbyte = 1000 +defaultpayloadlengthextrabytes = 1000 +minimizeonclose = false +replybelow = False +maxdownloadrate = 0 +maxuploadrate = 0 +stopresendingafterxdays = +stopresendingafterxmonths = +sockslisten = false +userlocale = system +sendoutgoingconnections = True +useidenticons = True +identiconsuffix = qcqQGW6sQtZK +maxacceptablenoncetrialsperbyte = 20000000000 +maxacceptablepayloadlengthextrabytes = 20000000000 +onionhostname = +onionport = 8444 +onionbindip = 127.0.0.1 +smtpdeliver = +hidetrayconnectionnotifications = false +ttl = 367200 + +[BM-2cTpgCn57rYUgqm5BrgmykuV9gK1Ak1THF] +label = test1 +enabled = true +decoy = false +noncetrialsperbyte = 1000 +payloadlengthextrabytes = 1000 +privsigningkey = 5KYCPJ4Vp31UD6k5NWmDKtHhfapW25UJ7V2MjctYxcgL3BpWGA3 +privencryptionkey = 5JLER8q2zyj3KDEgGMv682en2SRUkkWWhUrNuqVYfGNNhHJmdkJ +lastpubkeysendtime = 1623160189 + +[BM-2cVrdzQjCQRqUuET6dc3byVyRTjZcgcJXj] +label = test2 +enabled = true +decoy = false +noncetrialsperbyte = 1000 +payloadlengthextrabytes = 1000 +privsigningkey = 5KhryWvNowFWWA9JRjQnLVStYKwhpKpAG4RtWwzyaQqmK2fTMue +privencryptionkey = 5JKQ9NqX2LRzHBCgyxc1GAL3rDvyDTHPifpL22a6UNN7K6y9BmL +lastpubkeysendtime = 1623160221 + diff --git a/src/bitmessagekivy/tests/sampleData/knownnodes.dat b/src/bitmessagekivy/tests/sampleData/knownnodes.dat new file mode 100644 index 00000000..41ba8a28 --- /dev/null +++ b/src/bitmessagekivy/tests/sampleData/knownnodes.dat @@ -0,0 +1,110 @@ +[ + { + "stream": 1, + "peer": { + "host": "5.45.99.75", + "port": 8444 + }, + "info": { + "lastseen": 1620741290.255359, + "rating": 0, + "self": false + } + }, + { + "stream": 1, + "peer": { + "host": "75.167.159.54", + "port": 8444 + }, + "info": { + "lastseen": 1620741290.255359, + "rating": 0, + "self": false + } + }, + { + "stream": 1, + "peer": { + "host": "95.165.168.168", + "port": 8444 + }, + "info": { + "lastseen": 1620741290.255359, + "rating": 0, + "self": false + } + }, + { + "stream": 1, + "peer": { + "host": "85.180.139.241", + "port": 8444 + }, + "info": { + "lastseen": 1620741290.255359, + "rating": 0, + "self": false + } + }, + { + "stream": 1, + "peer": { + "host": "158.222.217.190", + "port": 8080 + }, + "info": { + "lastseen": 1620741290.255359, + "rating": 0, + "self": false + } + }, + { + "stream": 1, + "peer": { + "host": "178.62.12.187", + "port": 8448 + }, + "info": { + "lastseen": 1620741290.255359, + "rating": 0, + "self": false + } + }, + { + "stream": 1, + "peer": { + "host": "24.188.198.204", + "port": 8111 + }, + "info": { + "lastseen": 1620741290.255359, + "rating": 0, + "self": false + } + }, + { + "stream": 1, + "peer": { + "host": "109.147.204.113", + "port": 1195 + }, + "info": { + "lastseen": 1620741290.255359, + "rating": 0, + "self": false + } + }, + { + "stream": 1, + "peer": { + "host": "178.11.46.221", + "port": 8444 + }, + "info": { + "lastseen": 1620741290.255359, + "rating": 0, + "self": false + } + } +] \ No newline at end of file diff --git a/src/bitmessagekivy/tests/sampleData/messages.dat b/src/bitmessagekivy/tests/sampleData/messages.dat new file mode 100644 index 00000000..ad9aae5f Binary files /dev/null and b/src/bitmessagekivy/tests/sampleData/messages.dat differ diff --git a/src/bitmessagekivy/tests/sampleData/singleton.lock b/src/bitmessagekivy/tests/sampleData/singleton.lock index 828d8429..97ee3ea3 100644 --- a/src/bitmessagekivy/tests/sampleData/singleton.lock +++ b/src/bitmessagekivy/tests/sampleData/singleton.lock @@ -1 +1 @@ -18675 +16342 diff --git a/src/bitmessagekivy/tests/telenium_process.py b/src/bitmessagekivy/tests/telenium_process.py index b4f05905..fe447a87 100644 --- a/src/bitmessagekivy/tests/telenium_process.py +++ b/src/bitmessagekivy/tests/telenium_process.py @@ -36,7 +36,7 @@ def set_temp_data(): class TeleniumTestProcess(TeleniumTestCase): """Setting Screen Functionality Testing""" - cmd_entrypoint = [os.path.join(os.path.abspath(os.getcwd()), 'main_test.py')] + cmd_entrypoint = [os.path.join(os.path.abspath(os.getcwd()), 'src', 'main_test.py')] @classmethod def setUpClass(cls): diff --git a/src/bitmessagekivy/tests/test_addressbook.py b/src/bitmessagekivy/tests/test_addressbook.py index 169fb8c6..20be1c0a 100644 --- a/src/bitmessagekivy/tests/test_addressbook.py +++ b/src/bitmessagekivy/tests/test_addressbook.py @@ -1,5 +1,4 @@ - -from bitmessagekivy.tests.telenium_process import TeleniumTestProcess +from .telenium_process import TeleniumTestProcess from .common import ordered data = [ diff --git a/src/bitmessagekivy/tests/test_allmail_message.py b/src/bitmessagekivy/tests/test_allmail_message.py index dac9657a..0c34e474 100644 --- a/src/bitmessagekivy/tests/test_allmail_message.py +++ b/src/bitmessagekivy/tests/test_allmail_message.py @@ -1,4 +1,4 @@ -from bitmessagekivy.tests.telenium_process import TeleniumTestProcess +from .telenium_process import TeleniumTestProcess from .common import ordered diff --git a/src/bitmessagekivy/tests/test_create_random_address.py b/src/bitmessagekivy/tests/test_create_random_address.py index c5d4589b..995a955a 100644 --- a/src/bitmessagekivy/tests/test_create_random_address.py +++ b/src/bitmessagekivy/tests/test_create_random_address.py @@ -1,7 +1,7 @@ import os import tempfile -from bitmessagekivy.tests.telenium_process import TeleniumTestProcess, cleanup +from .telenium_process import TeleniumTestProcess, cleanup from .common import ordered from random import choice from string import ascii_lowercase diff --git a/src/bitmessagekivy/tests/test_draft_message.py b/src/bitmessagekivy/tests/test_draft_message.py index 462bdcf9..4e4467e9 100644 --- a/src/bitmessagekivy/tests/test_draft_message.py +++ b/src/bitmessagekivy/tests/test_draft_message.py @@ -1,4 +1,4 @@ -from bitmessagekivy.tests.telenium_process import TeleniumTestProcess +from .telenium_process import TeleniumTestProcess from .common import ordered diff --git a/src/bitmessagekivy/tests/test_myaddress_screen.py b/src/bitmessagekivy/tests/test_myaddress_screen.py index 878e53df..c017b763 100644 --- a/src/bitmessagekivy/tests/test_myaddress_screen.py +++ b/src/bitmessagekivy/tests/test_myaddress_screen.py @@ -1,4 +1,4 @@ -from bitmessagekivy.tests.telenium_process import TeleniumTestProcess +from .telenium_process import TeleniumTestProcess from .common import ordered data = [ diff --git a/src/bitmessagekivy/tests/test_network_screen.py b/src/bitmessagekivy/tests/test_network_screen.py index cb708559..6eb921cf 100644 --- a/src/bitmessagekivy/tests/test_network_screen.py +++ b/src/bitmessagekivy/tests/test_network_screen.py @@ -1,4 +1,4 @@ -from bitmessagekivy.tests.telenium_process import TeleniumTestProcess +from .telenium_process import TeleniumTestProcess class NetwrokStatusScreen(TeleniumTestProcess): diff --git a/src/bitmessagekivy/tests/test_payment_subscription.py b/src/bitmessagekivy/tests/test_payment_subscription.py index 1e8da4e8..165e53cd 100644 --- a/src/bitmessagekivy/tests/test_payment_subscription.py +++ b/src/bitmessagekivy/tests/test_payment_subscription.py @@ -1,4 +1,4 @@ -from bitmessagekivy.tests.telenium_process import TeleniumTestProcess +from .telenium_process import TeleniumTestProcess class PaymentScreen(TeleniumTestProcess): diff --git a/src/bitmessagekivy/tests/test_sent_message.py b/src/bitmessagekivy/tests/test_sent_message.py index 6a961a63..d15c1809 100644 --- a/src/bitmessagekivy/tests/test_sent_message.py +++ b/src/bitmessagekivy/tests/test_sent_message.py @@ -1,4 +1,4 @@ -from bitmessagekivy.tests.telenium_process import TeleniumTestProcess +from .telenium_process import TeleniumTestProcess from .common import ordered data = [ diff --git a/src/bitmessagekivy/tests/test_setting_screen.py b/src/bitmessagekivy/tests/test_setting_screen.py index 4f8798db..b6d9933a 100644 --- a/src/bitmessagekivy/tests/test_setting_screen.py +++ b/src/bitmessagekivy/tests/test_setting_screen.py @@ -1,4 +1,4 @@ -from bitmessagekivy.tests.telenium_process import TeleniumTestProcess +from .telenium_process import TeleniumTestProcess class SettingScreen(TeleniumTestProcess): diff --git a/src/bitmessagekivy/tests/test_trash_message.py b/src/bitmessagekivy/tests/test_trash_message.py index 0a70538e..05371acf 100644 --- a/src/bitmessagekivy/tests/test_trash_message.py +++ b/src/bitmessagekivy/tests/test_trash_message.py @@ -1,4 +1,4 @@ -from bitmessagekivy.tests.telenium_process import TeleniumTestProcess +from .telenium_process import TeleniumTestProcess class TrashMessage(TeleniumTestProcess): @@ -19,6 +19,6 @@ class TrashMessage(TeleniumTestProcess): self.cli.sleep(4) self.cli.click_on('//MDList[0]/CutsomSwipeToDeleteItem[0]//MDIconButton[0]') self.cli.sleep(2) - # self.cli.click_on('//MDDialog/MDCard[0]/AnchorLayout[0]/MDBoxLayout[0]/MDFlatButton[0]') - self.cli.click_on('//MDDialog/DialogFakeCard[0]/AnchorLayout[0]/MDBoxLayout[0]/MDFlatButton[0]') + self.cli.click_on('//MDDialog/MDCard[0]/AnchorLayout[0]/MDBoxLayout[0]/MDFlatButton[0]') + # self.cli.click_on('//MDDialog/DialogFakeCard[0]/AnchorLayout[0]/MDBoxLayout[0]/MDFlatButton[0]') self.cli.sleep(4) diff --git a/src/tests-kivy.py b/tests-kivy.py similarity index 89% rename from src/tests-kivy.py rename to tests-kivy.py index bdaf670e..92b10b86 100644 --- a/src/tests-kivy.py +++ b/tests-kivy.py @@ -9,7 +9,7 @@ def unittest_discover(): """Explicit test suite creation""" loader = unittest.defaultTestLoader loader.sortTestMethodsUsing = lambda a, b: random.randint(-1, 1) - return loader.discover('bitmessagekivy.tests') + return loader.discover('src.bitmessagekivy.tests') if __name__ == "__main__":