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

fix: migrate to common prism setup #888

Merged
merged 1 commit into from May 5, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -26,3 +26,4 @@ __pycache__
example.pdf
TODO.txt
twilio.env
prism
26 changes: 12 additions & 14 deletions .travis.yml
@@ -1,27 +1,25 @@
dist: xenial # required for Python >= 3.7
language: python
cache: pip
python:
- '2.7'
- '3.5'
- '3.6'
- '3.7'
- '3.8'
services:
- docker
env:
matrix:
- version=2.7
- version=3.5
- version=3.6
- version=3.7
- version=3.8
global:
- CC_TEST_REPORTER_ID=$TRAVIS_CODE_CLIMATE_TOKEN SENDGRID_API_KEY=SGAPIKEY
install:
- make install
- make test-install
- CC_TEST_REPORTER_ID=$TRAVIS_CODE_CLIMATE_TOKEN
before_script:
- "./test/prism.sh &"
- sleep 20
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
script:
- . venv/bin/activate; coverage run -m unittest discover
- make test-docker
after_script:
- make test-install
- . venv/bin/activate; codecov
- ./cc-test-reporter after-build --exit-code $?
deploy:
Expand All @@ -32,7 +30,7 @@ deploy:
distributions: sdist bdist_wheel
on:
tags: true
python: '3.6'
condition: $version=3.6

notifications:
slack:
Expand Down
12 changes: 12 additions & 0 deletions Dockerfile
@@ -0,0 +1,12 @@
ARG version=latest
FROM python:$version

RUN pip install virtualenv

COPY prism/prism/nginx/cert.crt /usr/local/share/ca-certificates/cert.crt
RUN update-ca-certificates

WORKDIR /app
COPY . .

RUN make install
14 changes: 9 additions & 5 deletions Makefile
@@ -1,4 +1,4 @@
.PHONY: venv install test-install test clean nopyc
.PHONY: venv install test-install test test-integ test-docker clean nopyc

venv:
@python --version || (echo "Python is not installed, please install Python 2 or Python 3"; exit 1);
Expand All @@ -8,13 +8,17 @@ install: venv
. venv/bin/activate; python setup.py install
. venv/bin/activate; pip install -r requirements.txt

test-install:
test-install: install
. venv/bin/activate; pip install -r test/requirements.txt

test: test-install
./test/prism.sh &
sleep 2
. venv/bin/activate; python -m unittest discover -v

test-integ: test
. venv/bin/activate; coverage run -m unittest discover

version ?= latest
test-docker:
curl -s https://raw.githubusercontent.com/sendgrid/sendgrid-oai/master/prism/prism.sh | version=$(version) bash

clean: nopyc
rm -rf venv
Expand Down
58 changes: 0 additions & 58 deletions test/prism.sh

This file was deleted.

8 changes: 2 additions & 6 deletions test/test_sendgrid.py
Expand Up @@ -5,18 +5,15 @@
import sendgrid
from sendgrid.helpers.endpoints.ip.unassigned import unassigned

host = "http://localhost:4010"


class UnitTests(unittest.TestCase):

@classmethod
def setUpClass(cls):
cls.host = host
cls.path = '{}{}'.format(
os.path.abspath(
os.path.dirname(__file__)), '/..')
cls.sg = sendgrid.SendGridAPIClient(host=host)
cls.sg = sendgrid.SendGridAPIClient()
cls.devnull = open(os.devnull, 'w')

def test_api_key_init(self):
Expand All @@ -34,7 +31,6 @@ def test_api_key_setter(self):
def test_impersonate_subuser_init(self):
temp_subuser = 'abcxyz@this.is.a.test.subuser'
sg_impersonate = sendgrid.SendGridAPIClient(
host=host,
impersonate_subuser=temp_subuser)
self.assertEqual(sg_impersonate.impersonate_subuser, temp_subuser)

Expand All @@ -43,7 +39,7 @@ def test_useragent(self):
self.assertEqual(self.sg.useragent, useragent)

def test_host(self):
self.assertEqual(self.sg.host, self.host)
self.assertEqual(self.sg.host, 'https://api.sendgrid.com')

def test_get_default_headers(self):
headers = self.sg._default_headers
Expand Down