Commit cf232414a1ec3aae351b17af4cf827cc7b639ad2
1 parent
61ef8379b7
Exists in
master
start writing fixtures
Showing 5 changed files with 66 additions and 3 deletions Side-by-side Diff
README.md
View file @
cf23241
... | ... | @@ -15,7 +15,7 @@ |
15 | 15 | |
16 | 16 | Flashy's code is divided among the flashy-backend repository (this one!) and the flashy-frontend repository. When running the local server, these repositories should be sibling directories and the flashy-frontend repository must be cloned into a directory of the same name. |
17 | 17 | |
18 | -Flashy officially supports Ubuntu 14.04 | |
18 | +Flashy officially supports Ubuntu 14.04 with at least 2 GB of RAM. A VM is acceptable but performance may be impaired. | |
19 | 19 | |
20 | 20 | ## Installing Flashy on Ubuntu 14.04 (development/testing) |
21 | 21 | |
... | ... | @@ -29,7 +29,14 @@ |
29 | 29 | ### Install required packages |
30 | 30 | |
31 | 31 | sudo apt-get install python-virtualenv redis-server git python-dev |
32 | - | |
32 | + | |
33 | +### Start Redis | |
34 | + | |
35 | + sudo service redis_6379 start | |
36 | + echo PING | redis-cli | |
37 | + | |
38 | +Redis should respond PONG to the last command. | |
39 | + | |
33 | 40 | ### Prepare installation directory |
34 | 41 | |
35 | 42 | mkdir ~/flashy/ |
... | ... | @@ -56,7 +63,11 @@ |
56 | 63 | |
57 | 64 | scripts/run_local.sh |
58 | 65 | |
59 | -When run in development, emails will be printed to the terminal and not actually sent. | |
66 | +You should be able to access the application at http://127.0.0.1:8080/app/ | |
67 | + | |
68 | +## Email on the Locally Server | |
69 | + | |
70 | +In production, Flashy uses AWS SES to send emails. However, we did not want to bundle the AWS key with the source of our app, so when run locally, Flashy falls back to the ConsoleBackend. In practice, this means that when run in development, emails will be printed to the terminal and not actually sent. | |
60 | 71 | |
61 | 72 | ## Troubleshooting |
62 | 73 |
flashcards/management/commands/apply_test_fixture.py
View file @
cf23241
1 | +from django.core.management import BaseCommand | |
2 | +from django.utils.importlib import import_module | |
3 | +from flashcards.test_fixtures import base | |
4 | + | |
5 | + | |
6 | +class Command(BaseCommand): | |
7 | + help = 'Apply a test fixture' | |
8 | + | |
9 | + def add_arguments(self, parser): | |
10 | + parser.add_argument('fixture_names', nargs='+', type=str) | |
11 | + | |
12 | + def handle(self, *args, **options): | |
13 | + base.apply() | |
14 | + for fixture in options['fixture_names']: | |
15 | + module = import_module("flashcards.test_fixtures.%s" % fixture) | |
16 | + module.apply() |
flashcards/test_fixtures/__init__.py
View file @
cf23241
1 | +__author__ = 'andrew' |
flashcards/test_fixtures/base.py
View file @
cf23241
1 | +from datetime import time | |
2 | + | |
3 | +from flashcards.models import * | |
4 | + | |
5 | + | |
6 | +def apply(): | |
7 | + User.objects.filter(email='userx@flashy.cards').delete() | |
8 | + User.objects.filter(email='usery@flashy.cards').delete() | |
9 | + Section.objects.filter(department_abbreviation='TEST').delete() | |
10 | + s = Section.objects.create(instructor='Test Prof', | |
11 | + course_title='Intro to Testing', | |
12 | + course_num="101", | |
13 | + quarter="SP15", | |
14 | + department="Test Sciences", | |
15 | + department_abbreviation='TEST' | |
16 | + ) | |
17 | + Section.objects.create(instructor='Test Prof', | |
18 | + course_title='Advanced Testing', | |
19 | + course_num="102", | |
20 | + quarter="SP15", | |
21 | + department="Test Sciences", | |
22 | + department_abbreviation='TEST' | |
23 | + ) | |
24 | + LecturePeriod.objects.create(section=s, week_day=2, start_time=time(8), end_time=time(9)) | |
25 | + LecturePeriod.objects.create(section=s, week_day=3, start_time=time(9), end_time=time(10)) | |
26 | + User.objects.create_user('userx@flashy.cards', password='mynameisuserx') | |
27 | + User.objects.create_user('usery@flashy.cards', password='mynameisusery') |