Open MichaelPereira opened 7 years ago
I had the same problem. It seems to be SQLite related. By default an in memory SQLite db is created specifically for the test. I replaced the SQLite with a regular Postgresql and all 129 errors magically disappeared.
What I did (I had to figure out what to do step by step so this is probably not the most efficient approach -- works on my machine):
Start a postgres instance
docker run -d \
--name askbot-postgres-test \
-p 5432:5432 \
-e POSTGRES_PASSWORD=askbotPW \
postgres:10
Setup a database as described on this page
echo localhost:5432:postgres:postgres:askbotPW >.pgpass
chmod 600 .pgpass
psql -h localhost -p 5432 -U postgres --no-password
#The following commands are sent to the psql cli
CREATE USER askbot WITH PASSWORD 'askB0T!';
ALTER ROLE askbot SET client_encoding TO 'utf8';
ALTER ROLE askbot SET default_transaction_isolation TO 'read committed';
ALTER ROLE asḱbot SET timezone TO 'UTC';
ALTER USER askbot CREATEDB;
Modify testproject/testproject/settings.py
by replacing the line DATABASES = {'default': DATABASE}
with
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'askbottest',
'USER': 'askbot',
'PASSWORD': 'askB0T!',
'HOST': 'localhost',
'PORT': '5432',
'TEST_CHARSET': 'utf8',
}
}
Have tox
install psycopg2
:
echo psycopg2-binary >> requirements-tests.txt
The reward for all of the above looks a lot like this:
----------------------------------------------------------------------
Ran 681 tests in 413.193s
OK (skipped=5)
Found 3 unused tags: picasso, pissarro, renoir.
Deleted.
Destroying test database for alias 'default'...
So, the problem is that if any user is blocked, all next tests will fail when creating a new user, because the blocked status is re-used from the previous users.
regarding postgres:
export DATABASE_URL='postgres://askbot:askB0T!@localhost/askbottest'
and this line needs to be removed:
- 'COLLATION': 'utf8_general_ci', # is necessary for MySQL tests to work properly.
create DB was missing
CREATE DATABASE askbottest OWNER=askbot;
Problem description
Hi,
As I'm trying to make some changes into askbot, I wanted to make sure that I could run the test suite to make sure I'm not breaking anything in the process. However when trying to run the test suite, a significant amount of tests fail. The testing setup is explained after the tests results:
All error cases except 3 fail with the same error as below:
I tried to look into how a user account gets blocked, but after looking the user model in both askbot and django, I still can't find what's behind
user.is_blocked()
to look into what is causing this problem exactly. Could you please give me a hint @evgenyfadeev ?Reproducing
Since I was having issues running the tests locally on my mac laptop with tox, I created an optimized alpine-based docker image that runs the tests with the error above in a reproducible way. I'm planning to make a PR for it later after discussing it, but for now, you can check out the issue above by checking out that branch from my fork: https://github.com/MichaelPereira/askbot-devel/tree/docker-alpine-image then you can build the image and run the tests with: