Skip to content

Commit b402a4a

Browse files
refactor: Move tests to appropriate modules (#5500)
- Move tests to unit and integration modules - Fix and add tests for make_frontend_url
1 parent e34d385 commit b402a4a

35 files changed

+90
-42
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Fixes #
99

1010
- [ ] I have read the [Contribution & Best practices Guide](https://blog.fossasia.org/open-source-developer-guide-and-best-practices-at-fossasia) and my PR follows them.
1111
- [ ] My branch is up-to-date with the Upstream `development` branch.
12-
- [ ] The unit tests pass locally with my changes <!-- use `nosetests tests/unittests` to run all the tests -->
12+
- [ ] The unit tests pass locally with my changes <!-- use `nosetests tests/all` to run all the tests -->
1313
- [ ] I have added tests that prove my fix is effective or that my feature works
1414
- [ ] I have added necessary documentation (if appropriate)
1515
<!-- If an existing function does not have a docstring, please add one -->

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ before_script:
3535
- dredd
3636

3737
script:
38-
- nosetests tests/unittests -v --with-coverage
38+
- nosetests tests/all -v --with-coverage
3939

4040
after_success:
4141
- 'bash <(curl -s https://codecov.io/bash)'

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,13 @@ export APP_CONFIG=config.TestingConfig
204204

205205
* Then go to the project directory and run the following command:
206206
```
207-
python3 -m unittest discover tests/unittests/
207+
python3 -m unittest discover tests/all/
208208
```
209209
* It will run each test one by one.
210210

211211
* You can also use the following command to run tests using nosetests:
212212
```
213-
nosetests tests/unittests/
213+
nosetests tests/all/
214214
```
215215

216216
#### Running robot framework tests

app/api/helpers/files.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,13 @@ def make_frontend_url(path, parameters=None):
251251
Create URL for frontend
252252
"""
253253
settings = get_settings()
254-
frontend_url = urllib.parse.urlparse(settings['frontend_url'] if settings['frontend_url'] else '')
254+
frontend_url = urllib.parse.urlparse(settings.get('frontend_url') or '')
255+
256+
full_path = '/'.join(x.strip('/') for x in (frontend_url.path, str(path)) if x)
255257
return urllib.parse.urlunparse((
256258
frontend_url.scheme,
257259
frontend_url.netloc,
258-
str(path),
260+
full_path,
259261
'',
260262
str(urllib.parse.urlencode(parameters) if parameters else ''),
261263
''

create_db.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from app import current_app
88
from app.models import db
99
from populate_db import populate
10-
from tests.unittests.auth_helper import create_super_admin
10+
from tests.all.integration.auth_helper import create_super_admin
1111

1212

1313
def create_default_user(email, password):

manage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from flask_migrate import stamp
1111
from sqlalchemy.engine import reflection
1212

13-
from tests.unittests.auth_helper import create_super_admin
13+
from tests.all.integration.auth_helper import create_super_admin
1414

1515

1616
@manager.command
File renamed without changes.
File renamed without changes.

tests/unittests/api/helpers/test_db.py renamed to tests/all/integration/api/helpers/test_db.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
from app import current_app as app
44
from app.factories.attendee import AttendeeFactory
55
from app.models.ticket_holder import TicketHolder
6-
from tests.unittests.utils import OpenEventTestCase
6+
from tests.all.integration.utils import OpenEventTestCase
77
from app.factories.event import EventFactoryBasic
88
from app.api.helpers.db import save_to_db, safe_query, get_or_create, get_count
99
from flask_rest_jsonapi.exceptions import ObjectNotFound
1010
from app.models import db
1111
from app.models.event import Event
12-
from tests.unittests.setup_database import Setup
12+
from tests.all.integration.setup_database import Setup
1313

1414

1515
class TestDBHelperValidation(OpenEventTestCase):

0 commit comments

Comments
 (0)