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

remove outdated tests and mark the ones we need to skip for now #516

Merged
merged 7 commits into from
Dec 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 8 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
branches:
only:
- "/^v0.*$/"
- 2.5
- master
language: python
python:
Expand All @@ -10,12 +11,16 @@ install:
- pip install --upgrade pip
- pip install --upgrade -r requirements.txt
sudo: required
dist: trusty
group: deprecated-2017Q4

addons:
postgresql: '9.4'
apt:
packages:
- postgresql-9.4-postgis-2.4

before_script:
- mv configs/test_settings_deployment.py councilmatic/settings_deployment.py
- psql -U postgres -c "create extension postgis"
- mv configs/test_settings_deployment.py councilmatic/settings_deployment.py
script: python manage.py migrate && pytest
deploy:
- provider: codedeploy
Expand Down
27 changes: 11 additions & 16 deletions configs/test_settings_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

import os

import dj_database_url

ALLOWED_HOSTS = [
'localhost',
'127.0.0.1',
'0.0.0.0',
]

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'testing secrets'

Expand All @@ -12,23 +20,14 @@
# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'travis',
'USER': 'travis',
'PASSWORD': '',
'HOST': 'localhost',
'PORT': '5432',
}
}
DATABASES = {'default': dj_database_url.config(default='postgis://travis:/travis')}

HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
#'URL': 'http://127.0.0.1:8983/solr'
# ...or for multicore...
'URL': 'http://127.0.0.1:8983/solr/lametro',
'URL': os.environ.get('SOLR_URL') or 'http://127.0.0.1:8983/solr/lametro',
},
}

Expand All @@ -53,10 +52,6 @@
HEADSHOT_PATH = os.path.join(os.path.dirname(__file__), '..'
'/lametro/static/images/')

EXTRA_APPS = ('raven.contrib.django.raven_compat',)

RAVEN_CONFIG = {
'dsn': 'https://4a1f7af075cd4fd4bedebe4db50d9c3d:f49e4e9b89ed41e889f69be65b4f6f21@sentry.io/107858',
}
EXTRA_APPS = ()

SHOW_TEST_EVENTS = True
4 changes: 1 addition & 3 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
[pytest]
DJANGO_SETTINGS_MODULE = tests.test_config
filterwarnings =
ignore::django.utils.deprecation.RemovedInDjango20Warning
DJANGO_SETTINGS_MODULE = councilmatic.settings
98 changes: 73 additions & 25 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@

from django.core.management import call_command

from councilmatic_core.models import EventDocument, Bill, EventAgendaItem, Membership, LegislativeSession
from opencivicdata.legislative.models import (
LegislativeSession,
EventAgendaItem,
EventRelatedEntity,
)
from opencivicdata.core.models import Jurisdiction, Division
from opencivicdata.legislative.models import EventDocument
from councilmatic_core.models import Bill, Membership
from lametro.models import LAMetroPerson, LAMetroEvent, LAMetroBill, LAMetroOrganization

def get_uid_chunk(uid=None):
Expand All @@ -25,14 +32,14 @@ def bill(db, legislative_session):
class BillFactory():
def build(self, **kwargs):
bill_info = {
'ocd_id': 'ocd-bill/2436c8c9-564f-4cdd-a2ce-bcfe082de2c1',
'description': 'APPROVE the policy for a Measure M Early Project Delivery Strategy',
'ocd_created_at': '2017-06-09 13:06:21.10075-05',
'ocd_updated_at': '2017-06-09 13:06:21.10075-05',
'updated_at': '2017-07-26 11:06:47.1853',
'id': 'ocd-bill/2436c8c9-564f-4cdd-a2ce-bcfe082de2c1',
'title': 'APPROVE the policy for a Measure M Early Project Delivery Strategy',
'created_at': '2017-06-09 13:06:21.10075-05',
'updated_at': '2017-06-09 13:06:21.10075-05',
'identifier': '2017-0686',
'slug': '2017-0686',
'_legislative_session': legislative_session,
'classification': ['Report'],
'legislative_session': legislative_session,
}

bill_info.update(kwargs)
Expand All @@ -45,12 +52,34 @@ def build(self, **kwargs):

@pytest.fixture
@pytest.mark.django_db
def legislative_session(db):
def division(db):
division_info = {
'id': 'ocd-division/country:us/state:ca/county:los_angeles',
'name': 'LA'
}

division = Division.objects.create(**division_info)

return division

@pytest.fixture
@pytest.mark.django_db
def jurisdiction(db, division):
jurisdiction_info = {
'id': 'ocd-jurisdiction/country:us/state:ca/county:los_angeles/transit_authority',
'division_id': 'ocd-division/country:us/state:ca/county:los_angeles'}

jurisdiction = Jurisdiction.objects.create(**jurisdiction_info)

return jurisdiction

@pytest.fixture
@pytest.mark.django_db
def legislative_session(db, jurisdiction):
session_info = {
'identifier': '2017',
'jurisdiction_ocd_id': 'ocd-jurisdiction/country:us/state:ca/county:los_angeles/transit_authority',
'jurisdiction_id': 'ocd-jurisdiction/country:us/state:ca/county:los_angeles/transit_authority',
'name': '2017 Legislative Session',
'updated_at': '2019-02-07 08:34:56.455542-06',
}

session = LegislativeSession.objects.create(**session_info)
Expand All @@ -59,17 +88,17 @@ def legislative_session(db):

@pytest.fixture
@pytest.mark.django_db
def event(db):
def event(db, jurisdiction):
class EventFactory():
def build(self, **kwargs):
event_info = {
'ocd_id': 'ocd-event/17fdaaa3-0aba-4df0-9893-2c2e8e94d18d',
'ocd_created_at': '2017-05-27 11:10:46.574-05',
'ocd_updated_at': '2017-05-27 11:10:46.574-05',
'id': 'ocd-event/17fdaaa3-0aba-4df0-9893-2c2e8e94d18d',
'created_at': '2017-05-27 11:10:46.574-05',
'updated_at': '2017-05-27 11:10:46.574-05',
'name': 'System Safety, Security and Operations Committee',
'start_time': datetime.strptime('2017-05-18 12:15', '%Y-%m-%d %H:%M'),
'updated_at': '2017-05-17 11:06:47.1853',
'start_date': '2017-05-18 12:15',
'slug': uuid4(),
'jurisdiction': jurisdiction,
}

event_info.update(kwargs)
Expand All @@ -88,8 +117,7 @@ def build(self, **kwargs):
named_event = event.build()

event_agenda_item_info = {
'event_id': named_event.ocd_id,
'updated_at': '2017-05-27 11:10:46.574-05',
'event_id': named_event.id,
'order': 1,
}

Expand All @@ -102,21 +130,41 @@ def build(self, **kwargs):
return EventAgendaItemFactory()


@pytest.fixture
@pytest.mark.django_db
def event_related_entity(db, event_agenda_item):
class EventRelatedEntityFactory():
def build(self, **kwargs):
agenda_item = event_agenda_item.build()

event_related_entity_info = {
'agenda_item': agenda_item
}

event_related_entity_info.update(kwargs)

event_related_entity = EventRelatedEntity.objects.create(**event_related_entity_info)

return event_related_entity

return EventRelatedEntityFactory()


@pytest.fixture
@pytest.mark.django_db
def event_document(db):
class EventDocumentFactory():
def build(self, **kwargs):
event_document_info = {
'url': 'https://metro.legistar.com/View.ashx?M=A&ID=545192&GUID=19F05A99-F3FB-4354-969F-67BE32A46081',
'event_id': 'ocd-event/17fdaaa3-0aba-4df0-9893-2c2e8e94d18d',
'updated_at': '2017-05-16 11:06:47.1853'
}

event_document_info.update(kwargs)

event_document = EventDocument.objects.create(**event_document_info)

event_document.links.create(url='https://metro.legistar.com/View.ashx?M=A&ID=545192&GUID=19F05A99-F3FB-4354-969F-67BE32A46081')

return event_document

return EventDocumentFactory()
Expand All @@ -129,7 +177,7 @@ def build(self, **kwargs):
uid = str(uuid4())

person_info = {
'ocd_id': 'ocd-person/' + uid,
'id': 'ocd-person/' + uid,
'name': 'Wonder Woman',
'slug': 'wonder-woman-' + get_uid_chunk(uid),
}
Expand All @@ -150,7 +198,7 @@ def build(self, **kwargs):
uid = str(uuid4())

organization_info = {
'ocd_id': 'ocd-organization/' + uid,
'id': 'ocd-organization/' + uid,
'name': 'Planning and Programming Committee',
'slug': 'planning-and-programming-committee-' + get_uid_chunk(uid),
}
Expand All @@ -173,9 +221,9 @@ def build(self, **kwargs):

membership_info = {
'id': randrange(10000),
'_organization': related_org,
'_person': related_person,
'end_date': datetime.now() + timedelta(days=1)
'organization': related_org,
'person': related_person,
'end_date': (datetime.now() + timedelta(days=1)).date()
}

membership_info.update(kwargs)
Expand Down
6 changes: 6 additions & 0 deletions tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ services:
app:
restart: "no"
command: pytest -sxv
environment:
DATABASE_URL: 'postgis://postgres:postgres@postgres/lametro'
SOLR_URL: 'http://solr:8983/solr/lametro'
DJANGO_MANAGEPY_MIGRATE: "off"
volumes:
- ${PWD}/configs/test_settings_deployment.py:/app/councilmatic/settings_deployment.py
Loading