Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ai3
config
Commits
18c67ff1
Commit
18c67ff1
authored
May 30, 2020
by
godog
Browse files
test: port to Python 3
parent
7c616571
Pipeline
#6937
passed with stage
in 59 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
test/Dockerfile
View file @
18c67ff1
FROM
registry.git.autistici.org/ai3/float:integration-test
RUN
apt-get
-q
update
&&
env
DEBIAN_FRONTEND
=
noninteractive
\
apt-get
install
--no-install-recommends
-y
python python-pip python-setuptools python-yaml python-nose
ADD
. /config
WORKDIR
/config
RUN
python setup.py
install
RUN
python
3
setup.py
install
ENV
TEST_CONFIG=/test-config.yml
ENV
PYTHONPATH=/src
CMD
["nosetests", "-v", "ai3test"]
CMD
["nosetests
3
", "-v", "ai3test"]
test/README.md
View file @
18c67ff1
...
...
@@ -7,18 +7,18 @@ Per testare l'ambiente locale di test di ai3 (Vagrant), bisogna prima
installare alcuni prerequisiti. Anzitutto serve
*virtualenv*
, per
es. su una macchina Debian:
$ sudo apt
-get
install python-virtualenv
$ sudo apt install python
3
-virtualenv
Dopodiché bisogna creare una directory
*venv*
con un'installazione
locale di Python (per evitare di "sporcare" il sistema con le
dipendenze della suite di test):
$ virtualenv venv
$ virtualenv
--python python3
venv
Infine bisogna installare la test suite dentro questo ambiente Python
temporaneo:
$ ./venv/bin/python setup.py develop
$ ./venv/bin/python
3
setup.py develop
# Test
...
...
@@ -33,4 +33,4 @@ esempio, per testare l'ambiente locale Vagrant di default:
L'integrazione con 'float' avviene tramite un playbook apposito (ai3-test):
$ ANSIBLE_STDOUT_CALLBACK=minimal ../../float/float run ../../
rules
/playbooks/ai3-test.yml
$ ANSIBLE_STDOUT_CALLBACK=minimal ../../float/float run ../../
config
/playbooks/ai3-test.yml
test/ai3test/test_web_users.py
View file @
18c67ff1
import
urllib
2
import
urllib
.request
,
urllib
.
error
,
urllib
.
parse
from
ai3test
import
AI3_TEST_PARAMS
,
ANSIBLE_VARS
,
TestBase
,
request
...
...
@@ -16,7 +16,7 @@ class WebUsersBase(TestBase):
endpoint
,
ANSIBLE_VARS
[
'domain_public'
][
0
],
path
)
handlers
=
[]
if
username
and
password
:
h
=
urllib
2
.
HTTPBasicAuthHandler
()
h
=
urllib
.
request
.
HTTPBasicAuthHandler
()
h
.
add_password
(
''
,
'/'
,
username
,
password
)
handlers
.
append
(
h
)
result
=
request
(
url
,
self
.
frontend_ip
(),
handlers
=
handlers
)
...
...
@@ -48,4 +48,4 @@ class SubsiteTest(WebUsersBase):
url
=
'https://www.%s/%s'
%
(
ANSIBLE_VARS
[
'domain_public'
][
0
],
username
)
result
=
request
(
url
,
self
.
frontend_ip
())
self
.
assertEqual
s
(
result
[
'location'
],
url
+
'/'
)
self
.
assertEqual
(
result
[
'location'
],
url
+
'/'
)
test/setup.py
View file @
18c67ff1
#!/usr/bin/python
from
setuptools
import
setup
,
find_packages
setup
(
...
...
test/tox.ini
View file @
18c67ff1
[tox]
envlist
=
py
27
envlist
=
py
3
[testenv]
passenv
=
TEST_CONFIG
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment