diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..f5f4cf4 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,42 @@ +version: 2 +jobs: + build: + working_directory: ~/django-api + docker: + - image: circleci/python:3.6.4 + environment: + PIPENV_VENV_IN_PROJECT: true + DJANGO_SECRET_KEY: qAhCPjJP5wrixDBf0qhQd62TxJ0CirclECi + DJANGO_DEBUG: True + DB_POSTGRES_DATABASE_NAME: circle_test + DB_POSTGRES_USERNAME: root + DB_POSTGRES_PASSWORD: '' + DB_POSTGRES_HOSTNAME: localhost + DB_POSTGRES_PORT: 5432 + API_SERVICES_URL: http://localhost:9000/services/api/ + FRONTEND_APP_URL: http://localhost:3000/ + + - image: circleci/postgres:9.6.2 + environment: + POSTGRES_USER: root + POSTGRES_DB: circle_test + POSTGRES_PASSWORD: '' + steps: + - checkout + - run: sudo chown -R circleci:circleci /usr/local/bin + - run: sudo chown -R circleci:circleci /usr/local/lib/python3.6/site-packages + - restore_cache: + key: deps9-{{ .Branch }}-{{ checksum "requirements.txt" }} + - run: + command: | + sudo pip install pipenv + pipenv install + - save_cache: + key: deps9-{{ .Branch }}-{{ checksum "requirements.txt" }} + paths: + - ".venv" + - "/usr/local/bin" + - "/usr/local/lib/python3.6/site-packages" + - run: + command: | + pipenv run "python manage.py test" diff --git a/accounts/tests.py b/accounts/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/accounts/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/accounts/tests/test_requests/__init__.py b/accounts/tests/test_requests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/accounts/tests/test_requests/test_users.py b/accounts/tests/test_requests/test_users.py index a5e505d..e80485e 100644 --- a/accounts/tests/test_requests/test_users.py +++ b/accounts/tests/test_requests/test_users.py @@ -14,8 +14,6 @@ def test_patient_current_user_get(self): """ Ensure we get a user. """ - user = User.objects.create(username="helloworld") - response = self.client.get("/services/api/users", content_type=self.content_type) @@ -23,4 +21,4 @@ def test_patient_current_user_get(self): response_data = json.loads(response.content) attributes = json.loads(response.content)['data'][0]['attributes'] - attributes['username'].should.equal(user.username) + attributes['username'].should.equal('codecorgi') diff --git a/profile/tests/test_requests/__init__.py b/profile/tests/test_requests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/profile/tests/test_requests/test_profile.py b/profile/tests/test_requests/test_profile.py index cc01cb5..5c0f12f 100644 --- a/profile/tests/test_requests/test_profile.py +++ b/profile/tests/test_requests/test_profile.py @@ -1,6 +1,5 @@ from django.test import TestCase from rest_framework.test import APIClient, APITestCase -from accounts.models import User from profile.models import Profile, ProfileURL import sure import json @@ -14,9 +13,8 @@ def test_profile_create_with_user(self): """ Ensure we get the correct profile """ - user = User.objects.create(username="husky") - profile = Profile.objects.create(user=user, bio="Woof!") + profile = Profile.objects.filter().last() response = self.client.get("/services/api/profiles", content_type=self.content_type) @@ -27,15 +25,14 @@ def test_profile_create_with_user(self): attributes = response_data['data'][0]['attributes'] relationships = response_data['data'][0]['relationships'] attributes['bio'].should.equal(profile.bio) - relationships['user']['data']['id'].should.equal(str(user.id)) + relationships['user']['data']['id'].should.equal(str(profile.user.id)) def test_profile_create_with_urls(self): """ Ensure we get the correct profile and project urls """ - user = User.objects.create(username="poodle") - profile = Profile.objects.create(user=user, bio="Woof! in French") + profile = Profile.objects.filter().last() url1 = ProfileURL.objects.create(profile=profile, name='codecorgi', url='https://codecorgi.co') url2 = ProfileURL.objects.create(profile=profile, name='codecorgi gh', url=None)