← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~pappacena/turnip:py3-http-auth-testfix into turnip:master

 

Thiago F. Pappacena has proposed merging ~pappacena/turnip:py3-http-auth-testfix into turnip:master with ~pappacena/turnip:py3-repo-creation-check as a prerequisite.

Commit message:
Fixing HTTP auth tests and reorganizing python3 test runner

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pappacena/turnip/+git/turnip/+merge/394375

This MP fixes the last tests incompatible with py3, and reorganizes the Makefile so that `make test` (and `make check`) always run tests on both python2 and python3.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~pappacena/turnip:py3-http-auth-testfix into turnip:master.
diff --git a/Makefile b/Makefile
index a47e5aa..0b9d1b1 100644
--- a/Makefile
+++ b/Makefile
@@ -70,9 +70,17 @@ bootstrap-test:
 	-sudo rabbitmqctl add_vhost turnip-test-vhost
 	-sudo rabbitmqctl set_permissions -p "turnip-test-vhost" "guest" ".*" ".*" ".*"
 
-test: $(ENV) bootstrap-test
+run-test: $(ENV) bootstrap-test
 	$(PYTHON) -m unittest discover $(ARGS) turnip
 
+test: test-python2 test-python3
+
+test-python2:
+	$(MAKE) run-test VENV_ARGS="-p python2"
+
+test-python3:
+	$(MAKE) run-test VENV_ARGS="-p python3" ENV="$(PY3_ENV)"
+
 clean:
 	find turnip -name '*.py[co]' -exec rm '{}' \;
 	rm -rf $(ENV) $(PY3_ENV) $(PIP_CACHE)
@@ -94,34 +102,7 @@ lint: $(ENV)
 pip-check: $(ENV)
 	$(PIP) check
 
-check: pip-check test lint check-python3-partial
-
-# This rule should be removed once all tests are running in python3.
-# Meanwhile, let's keep this list up-to-date and make sure we won't have
-# regressions.
-check-python3-partial:
-	$(MAKE) build VENV_ARGS="-p python3" ENV="$(PY3_ENV)"
-	# XXX: Tests not passing on python3 yet:
-	# turnip.pack.tests.test_functional.TestSmartHTTPFrontendWithAuthFunctional
-	$(PY3_ENV)/bin/python -m unittest \
-		turnip.api.tests.test_api \
-		turnip.api.tests.test_helpers \
-		turnip.api.tests.test_store \
-		turnip.pack.tests.test_git \
-		turnip.pack.tests.test_helpers \
-		turnip.pack.tests.test_hookrpc \
-		turnip.pack.tests.test_hooks \
-		turnip.pack.tests.test_http \
-		turnip.pack.tests.test_ssh \
-		turnip.pack.tests.test_functional.TestBackendFunctional \
-		turnip.pack.tests.test_functional.TestGitFrontendFunctional \
-		turnip.pack.tests.test_functional.TestSmartSSHServiceFunctional \
-		turnip.pack.tests.test_functional.TestSmartHTTPFrontendFunctional
-
-check-python3:
-	$(MAKE) check VENV_ARGS="-p python3" ENV="$(PY3_ENV)"
-
-check-python-compat: check check-python3
+check: pip-check test lint
 
 run-api: $(ENV)
 	$(PSERVE) api.ini --reload
diff --git a/turnip/pack/tests/test_functional.py b/turnip/pack/tests/test_functional.py
index eb52f62..dedaeb5 100644
--- a/turnip/pack/tests/test_functional.py
+++ b/turnip/pack/tests/test_functional.py
@@ -887,16 +887,16 @@ class TestSmartHTTPFrontendWithAuthFunctional(TestSmartHTTPFrontendFunctional):
         yield self.assertCommandSuccess((b'git', b'clone', self.ro_url, clone))
         expected_requests = 1 if self.protocol_version in (b'0', b'1') else 2
         self.assertEqual(
-            [(b'test-user', b'test-password')] * expected_requests,
+            [('test-user', 'test-password')] * expected_requests,
             self.virtinfo.authentications)
         self.assertEqual(expected_requests, len(self.virtinfo.translations))
         for translation in self.virtinfo.translations:
             self.assertThat(translation, MatchesListwise([
-                Equals(b'/test'), Equals(b'read'),
+                Equals('/test'), Equals('read'),
                 MatchesDict({
-                    b'can-authenticate': Is(True),
-                    b'request-id': Not(Is(None)),
-                    b'user': Equals(b'test-user')})
+                    'can-authenticate': Is(True),
+                    'request-id': Not(Is(None)),
+                    'user': Equals('test-user')})
                 ]))
 
     @defer.inlineCallbacks
@@ -919,9 +919,9 @@ class TestSmartHTTPFrontendWithAuthFunctional(TestSmartHTTPFrontendFunctional):
                 Equals(self.internal_name),
                 Equals([b'refs/heads/master']),
                 MatchesDict({
-                    b'can-authenticate': Is(True),
-                    b'request-id': Not(Is(None)),
-                    b'user': Equals(b'test-user'),
+                    'can-authenticate': Is(True),
+                    'request-id': Not(Is(None)),
+                    'user': Equals('test-user'),
                     })])]))