Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

just a test #2

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4deb18a
Start of factories
jonathan-s Oct 22, 2018
67e09e8
Fix flake issues
jonathan-s Oct 29, 2018
31a31ee
Add LocationFeeFactory
jonathan-s Oct 29, 2018
7249478
Outline of most factories needed
jonathan-s Oct 29, 2018
1a0dbab
Fix flake errors in events models
jonathan-s Oct 29, 2018
52a8fc8
Factories for events
jonathan-s Oct 30, 2018
b28d490
Fix bug with imports
jonathan-s Oct 30, 2018
17c59c9
Start of payment factories
jonathan-s Oct 30, 2018
e17d5bf
Communications factory
jonathan-s Oct 30, 2018
6f5d23d
Capitalize Faker
jonathan-s Oct 30, 2018
ca3852c
Payment factories
jonathan-s Oct 30, 2018
9c3e75d
Fix errors when generating data
jonathan-s Oct 30, 2018
dffaafe
Command to generate test data
jonathan-s Oct 30, 2018
102f52e
Fix bug with with location url that allows hyphen in url
jonathan-s Oct 30, 2018
2cb29ab
Remove unused RoomImage and LocationImage factory model
jonathan-s Oct 30, 2018
2344082
Sorting out errors for postgres and adding test
jonathan-s Nov 4, 2018
4fa52c1
Settings draft
jonathan-s Oct 20, 2018
2d00654
Modify new settings, hattip to @bfirsh
jonathan-s Oct 22, 2018
4f77c66
Delete all old settings
jonathan-s Oct 22, 2018
32502e1
Make sure that manage.py and wsgi run sane defaults
jonathan-s Oct 22, 2018
e1f4312
Use sqlite as default.
bfirsh Oct 23, 2018
e280bed
Fix up database settings
jonathan-s Oct 23, 2018
c407ecd
Pull correct docker python
bfirsh Nov 4, 2018
f80f9b9
Remove weird empty space
bfirsh Nov 4, 2018
0c2567d
Add COMPRESS_OFFLINE back to production settings
bfirsh Nov 4, 2018
3b021ba
Fix Docker development environment in new settings
bfirsh Nov 5, 2018
7c1cb0f
Fix Celery settings for Heroku
bfirsh Nov 5, 2018
f7c77ac
Add app.json
bfirsh Nov 5, 2018
7c82858
just a test
bfirsh Nov 5, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ cache:
- node_modules
services:
- postgresql
env:
- DJANGO_SETTINGS_MODULE=modernomad.settings.local
DATABASE_URL=postgres://postgres@localhost/test_db
install:
- "pip install -U pip wheel"
- "nvm install 8"
- "pip install -r requirements.txt -r requirements.test.txt"
before_script:
- psql -c 'create database test_db;' -U postgres
- "cd client && npm install && cd .."
- "cd client && ./node_modules/.bin/webpack --config webpack.prod.config.js && cd .."
- "cp modernomad/local_settings.travis.py modernomad/local_settings.py"
script: ./manage.py test
notifications:
slack:
Expand Down
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:2-alpine
FROM python:3.6.6-alpine3.8

# So Pillow can find zlib
ENV LIBRARY_PATH /lib:/usr/lib
Expand Down Expand Up @@ -38,8 +38,7 @@ RUN cd client && node_modules/.bin/webpack --config webpack.prod.config.js

# Set configuration last so we can change this without rebuilding the whole
# image
ENV DJANGO_SETTINGS_MODULE modernomad.settings_docker
ENV MODE PRODUCTION
ENV DJANGO_SETTINGS_MODULE modernomad.settings.production
# Number of gunicorn workers
ENV WEB_CONCURRENCY 3
EXPOSE 8000
Expand Down
8 changes: 8 additions & 0 deletions api/tests/commands/test_data_generation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.test import TransactionTestCase
from django.core.management import call_command


class DataGenerationTest(TransactionTestCase):

def test_run_data_generation(self):
call_command('generate_test_data')
30 changes: 30 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "modernomad",
"scripts": {
},
"env": {
"ALLOWED_HOSTS": ".herokuapp.com",
"AWS_ACCESS_KEY_ID": {
"required": true
},
"AWS_SECRET_ACCESS_KEY": {
"required": true
},
"AWS_STORAGE_BUCKET_NAME": {
"required": true
},
"SECRET_KEY": {
"generator": "secret"
}
},
"formation": {
"worker": {
"quantity": 1
},
"web": {
"quantity": 1
}
},
"addons": ["cloudamqp", "papertrail", "heroku-postgresql"],
"buildpacks": []
}
28 changes: 28 additions & 0 deletions core/factory_apps/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from faker import Faker
from faker.providers import lorem
from faker.providers import profile
from faker.providers import address
from faker.providers import python
from faker.providers import date_time
from faker.providers import misc
from faker.providers import BaseProvider
import factory

factory.Faker.add_provider(misc)
factory.Faker.add_provider(date_time)
factory.Faker.add_provider(python)
factory.Faker.add_provider(lorem)
factory.Faker.add_provider(profile)
factory.Faker.add_provider(address)


class Provider(BaseProvider):
# Note that the class name _must_ be ``Provider``.
def slug(self, name):
fake = Faker()
value = getattr(fake, name)()
return value.replace(' ', '-')


factory.Faker.add_provider(Provider)

9 changes: 9 additions & 0 deletions core/factory_apps/accounts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from . import factory


class HouseAccountFactory(factory.DjangoModelFactory):
pass


class UseTransactionFactory(factory.DjangoModelFactory):
pass
15 changes: 15 additions & 0 deletions core/factory_apps/communication.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from . import factory
from core import models
from .user import UserFactory


class EmailtemplateFactory(factory.DjangoModelFactory):
class Meta:
model = models.EmailTemplate

body = factory.Faker('paragraph')
subject = factory.Faker('words')
name = factory.Faker('words')
creator = factory.SubFactory(UserFactory)
shared = factory.Faker('pybool')
context = models.EmailTemplate.BOOKING
119 changes: 119 additions & 0 deletions core/factory_apps/events.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
from . import factory
from .location import LocationFactory

from gather.models import EventAdminGroup
from gather.models import EventSeries
from gather.models import Event
from gather.models import EventNotifications

from .user import UserFactory


class EventAdminGroupFactory(factory.DjangoModelFactory):
class Meta:
model = EventAdminGroup

location = factory.SubFactory(LocationFactory)

@factory.post_generation
def users(self, create, extracted, **kwargs):
if not create:
# Simple build, do nothing.
return

if extracted:
# A list of groups were passed in, use them
for user in extracted:
self.users.add(user)


class EventSeriesFactory(factory.DjangoModelFactory):
class Meta:
model = EventSeries

name = factory.Faker('word')
description = factory.Faker('paragraph')


class EventFactory(factory.DjangoModelFactory):
class Meta:
model = Event

created = factory.Faker('past_datetime')
updated = factory.Faker('past_datetime')
start = factory.Faker('future_datetime')
end = factory.Faker('future_datetime')

title = factory.Faker('words')
slug = factory.Faker('words')

description = factory.Faker('paragraph')
image = factory.django.ImageField(color='gray')

notifications = factory.Faker('pybool')

where = factory.Faker('city')
creator = factory.SubFactory(UserFactory)

organizer_notes = factory.Faker('paragraph')

limit = factory.Faker('random_digit')
visibility = Event.PUBLIC
status = Event.PENDING

location = factory.SubFactory(LocationFactory)
series = factory.SubFactory(EventSeriesFactory)
admin = factory.SubFactory(EventAdminGroupFactory)

@factory.post_generation
def attendees(self, create, extracted, **kwargs):
if not create:
return

if extracted:
for users in extracted:
self.attendees.add(users)

@factory.post_generation
def organizers(self, create, extracted, **kwargs):
if not create:
return

if extracted:
for users in extracted:
self.organizers.add(users)

@factory.post_generation
def endorsements(self, create, extracted, **kwargs):
if not create:
return

if extracted:
for users in extracted:
self.endorsements.add(users)


class EventNotificationFactory(factory.DjangoModelFactory):
class Meta:
model = EventNotifications

user = factory.SubFactory(UserFactory)
reminders = factory.Faker('pybool')

@factory.post_generation
def location_weekly(self, create, extracted, **kwargs):
if not create:
return

if extracted:
for location in extracted:
self.location_weekly.add(location)

@factory.post_generation
def location_publish(self, create, extracted, **kwargs):
if not create:
return

if extracted:
for location in extracted:
self.location_publish.add(location)
148 changes: 148 additions & 0 deletions core/factory_apps/location.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
from django.contrib.flatpages.models import FlatPage

from core.models import Location
from core.models import Resource
from core.models import LocationFee
from core.models import LocationMenu
from core.models import LocationFlatPage
from core.models import LocationEmailTemplate
from core.models import CapacityChange
from core.models import Fee
from . import factory


class FeeFactory(factory.DjangoModelFactory):
class Meta:
model = Fee

description = factory.Faker('text')
percentage = factory.Faker('pyfloat', left_digits=0, positive=True)
paid_by_house = factory.Faker('pybool')


class LocationFactory(factory.DjangoModelFactory):
class Meta:
model = Location
django_get_or_create = ('slug',)

name = factory.Faker('street_name')
slug = factory.Faker('slug', name='street_name')
short_description = factory.Faker('text')
address = factory.Faker('street_address')
image = factory.django.ImageField(color='blue')
profile_image = factory.django.ImageField(color='red')
latitude = factory.Faker('latitude')
longitude = factory.Faker('longitude')

welcome_email_days_ahead = factory.Faker('random_int')
max_booking_days = factory.Faker('random_int')

stay_page = factory.Faker('text')
front_page_stay = factory.Faker('text')
front_page_participate = factory.Faker('text')
announcement = factory.Faker('text')

house_access_code = factory.Faker('word')
ssid = factory.Faker('word')
ssid_password = factory.Faker('word')

timezone = factory.Faker('word')
bank_account_number = factory.Faker('random_int')
routing_number = factory.Faker('random_int')

bank_name = factory.Faker('word')
name_on_account = factory.Faker('word')
email_subject_prefix = factory.Faker('word')

check_out = factory.Faker('word')
check_in = factory.Faker('word')
visibility = factory.Iterator(['public', 'members', 'link'])

@factory.post_generation
def house_admins(self, create, extracted, **kwargs):
if not create:
# Simple build, do nothing.
return

if extracted:
# A list of groups were passed in, use them
for user in extracted:
self.house_admins.add(user)

@factory.post_generation
def readonly_admins(self, create, extracted, **kwargs):
if not create:
# Simple build, do nothing.
return

if extracted:
# A list of groups were passed in, use them
for user in extracted:
self.readonly_admins.add(user)


class ResourceFactory(factory.DjangoModelFactory):
class Meta:
model = Resource

name = factory.Faker('name')
location = factory.SubFactory(LocationFactory)
default_rate = factory.Faker('pydecimal', left_digits=0, positive=True)
description = factory.Faker('text')
summary = factory.Faker('sentence')
cancellation_policy = factory.Faker('text')
image = factory.django.ImageField(color='green')


class LocationFeeFactory(factory.DjangoModelFactory):
class Meta:
model = LocationFee

location = factory.SubFactory(LocationFactory)
fee = factory.SubFactory(FeeFactory)


class LocationMenuFactory(factory.DjangoModelFactory):
class Meta:
model = LocationMenu

location = factory.SubFactory(LocationFactory)
name = factory.Faker('text', max_nb_chars=15)


class FlatpageFactory(factory.DjangoModelFactory):
class Meta:
model = FlatPage


class LocationFlatPageFactory(factory.DjangoModelFactory):
class Meta:
model = LocationFlatPage

menu = factory.SubFactory(LocationMenuFactory)
flatpage = factory.SubFactory(FlatpageFactory)


class LocationEmailTemplateFactory(factory.DjangoModelFactory):
class Meta:
model = LocationEmailTemplate

location = factory.SubFactory(LocationFactory)
key = 'admin_daily_update'
text_body = factory.Faker('text')
html_body = factory.Faker('text')


class CapacityChangeFactory(factory.DjangoModelFactory):
class Meta:
model = CapacityChange

created = factory.Faker('past_datetime')
resource = factory.SubFactory(ResourceFactory)
start_date = factory.Faker('future_date')
quantity = factory.Faker('pyint')
accept_drft = factory.Faker('pybool')


class BackingFactory(factory.DjangoModelFactory):
pass
Loading