-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add flake8 to tests. * pep8 police * move flake8 config to .flake8 * fix pep8 args * add python3.5 and 3.6 to travis-ci * speed up tests * Add a general word-wrap style rule * Use docker image from dockerhub. Makefile with command alias * Adds gender field to EventRegistration model * Adds migration related to new gender field * Adds gender field to corresponding forms * Show the gender in registered list and CSV. * fix pep8 * Change the homepage context * Replaces Ultimas Noticias and Últmos Trabajos with a new section * Refactor the homepage as a class-based view * Added factories for testing * Added tests for the new homepage * Sanitize html inputs on Events and Jobs (#412) * fix autosuggest js on jobs form * refs #409 #410 add html_sanitizer to description field of Job and Event * refs #409 410 add tests to Job and Event views * remove duplicate requeriment * adjust code to pycodestyle * fix wrong exception class * Update job_form.html * added normalize_tags function on job utils (#418) * 407 migration to fix tags (#419) * Arreglo error de linter * Added new makemigrations shortcut * added missing migration * Adds a migration to clean the tags * split function to use ir * Use tag normalization function in migration * #346 autoslug (#420) * added autoslug fields to events * fixed url position * Fixed migrations (#423) * Resolviendo issue #383 (#425) * Resolviendo issue #383 Agregue el EMAIL_CONFIRMATION_LA_DOMAIN con el valor "python.org.ar". Probado en un servidor debug funciona correctamente el link. * arreglando error de flake8 * 417 sponsored jobs (#424) * Added rank for pycompanies, updated joblist view with sponsored jobs, added ac.civil badget to pycompanies * Changes after code review * moved css styles and other html stuff * Fixed typo and added one test with rank==0
- Loading branch information
Showing
46 changed files
with
846 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[flake8] | ||
max-line-length=99 | ||
exclude=migrations, .git, build.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
help: | ||
@echo "help -- print this help" | ||
@echo "start -- start docker stack" | ||
@echo "stop -- stop docker stack" | ||
@echo "ps -- show status" | ||
@echo "clean -- clean all artifacts" | ||
@echo "test -- run tests using docker" | ||
@echo "dockershell -- run bash inside docker" | ||
@echo "shell_plus -- run django shell_plus inside docker" | ||
@echo "bootstrap --build containers, run django migrations, load fixtures and create the a superuser" | ||
|
||
start: | ||
docker-compose up | ||
|
||
stop: | ||
docker-compose stop | ||
|
||
ps: | ||
docker-compose ps | ||
|
||
clean: stop | ||
docker-compose rm --force -v | ||
|
||
only_test: | ||
docker-compose run --rm web python3 ./manage.py test -v2 --noinput | ||
|
||
pep8: | ||
docker-compose run --rm web flake8 | ||
|
||
test: pep8 only_test | ||
|
||
dockershell: | ||
docker-compose run --rm web /bin/bash | ||
|
||
migrations: | ||
docker-compose run --rm web python3 manage.py makemigrations | ||
|
||
migrate: | ||
docker-compose run --rm web python3 manage.py migrate | ||
|
||
shell_plus: | ||
docker-compose run --rm web python3 manage.py shell_plus | ||
|
||
.PHONY: help start stop ps clean test dockershell shell_plus only_test pep8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
""" | ||
Tests for the community.views.HomePageView class | ||
""" | ||
from django.test import TestCase | ||
|
||
from community.views import HomePageView, RECENT_ITEMS_LEN | ||
from events.tests.factories import EventFactory | ||
from jobs.tests.factories import JobFactory | ||
from news.tests.factories import NewsArticleFactory | ||
|
||
|
||
class GetContextDataRecentKeyTests(TestCase): | ||
def setUp(self): | ||
# shortcut | ||
self.get_context_data = HomePageView().get_context_data | ||
|
||
def test_a_recent_key_is_added_to_the_return_value(self): | ||
self.assertIn('recent', self.get_context_data()) | ||
|
||
def test_events_are_included_in_recent(self): | ||
event = EventFactory() | ||
self.assertEqual([event], self.get_context_data()['recent']) | ||
|
||
def test_included_events_have_correct_fields(self): | ||
# Correct fields include 'category', 'created', 'title' and 'description' | ||
EventFactory() | ||
event = self.get_context_data()['recent'][0] | ||
self.assertEqual(event.category, 'Eventos') | ||
self.assertEqual(event.title, event.name) | ||
self.assertEqual(event.created, event.start_at) | ||
# Events already have a description field | ||
|
||
def test_jobs_are_included_in_recent(self): | ||
job = JobFactory() | ||
self.assertEqual([job], self.get_context_data()['recent']) | ||
|
||
def test_included_jobs_have_correct_fields(self): | ||
JobFactory() | ||
job = self.get_context_data()['recent'][0] | ||
self.assertEqual(job.category, 'Trabajos') | ||
# jobs already have 'created', 'title' and 'description' fields | ||
|
||
def test_news_are_included_in_recent(self): | ||
article = NewsArticleFactory() | ||
self.assertEqual([article], self.get_context_data()['recent']) | ||
|
||
def test_included_news_have_correct_fields(self): | ||
# Correct fields include 'category', 'created', 'title' and 'description' | ||
NewsArticleFactory() | ||
article = self.get_context_data()['recent'][0] | ||
self.assertEqual(article.category, 'Noticias') | ||
self.assertEqual(article.description, article.body) | ||
# NewsArticle already have a created and title fields | ||
|
||
# Independent of the Model type, all list items are sorted by their 'created' field | ||
def test_items_are_sorted_by_the_created_field(self): | ||
job = JobFactory(set_created='1985-10-26 09:00Z') # Middle-age ;-) | ||
event = EventFactory(start_at='1955-11-12 06:38Z') # Oldest | ||
article = NewsArticleFactory(set_created='2015-10-21 09:00Z') # Most recent | ||
# Assert the models are in chronological order | ||
self.assertListEqual([article, job, event], self.get_context_data()['recent']) | ||
|
||
def test_recent_is_a_list_with_at_most_10_items(self): | ||
# Create more than RECENT_ITEMS_LEN models and assert that only 10 are kept as recent | ||
for i in range(RECENT_ITEMS_LEN): | ||
JobFactory() | ||
EventFactory() | ||
NewsArticleFactory() | ||
# The loop above creates RECENT_ITEMS_LEN * 3 items | ||
self.assertEqual(len(self.get_context_data()['recent']), RECENT_ITEMS_LEN) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
-r requirements.txt | ||
factory-boy==2.8.1 | ||
ipython==5.3.0 | ||
ipdb==0.10.2 | ||
ipdb==0.10.2 | ||
flake8==3.5.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.