Skip to content

Commit ee02b30

Browse files
author
childish-sambino
authored
fix: migrate to common prism setup (#888)
1 parent 11d526c commit ee02b30

File tree

6 files changed

+36
-83
lines changed

6 files changed

+36
-83
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ __pycache__
2626
example.pdf
2727
TODO.txt
2828
twilio.env
29+
prism

.travis.yml

+12-14
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
dist: xenial # required for Python >= 3.7
22
language: python
33
cache: pip
4-
python:
5-
- '2.7'
6-
- '3.5'
7-
- '3.6'
8-
- '3.7'
9-
- '3.8'
4+
services:
5+
- docker
106
env:
7+
matrix:
8+
- version=2.7
9+
- version=3.5
10+
- version=3.6
11+
- version=3.7
12+
- version=3.8
1113
global:
12-
- CC_TEST_REPORTER_ID=$TRAVIS_CODE_CLIMATE_TOKEN SENDGRID_API_KEY=SGAPIKEY
13-
install:
14-
- make install
15-
- make test-install
14+
- CC_TEST_REPORTER_ID=$TRAVIS_CODE_CLIMATE_TOKEN
1615
before_script:
17-
- "./test/prism.sh &"
18-
- sleep 20
1916
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
2017
- chmod +x ./cc-test-reporter
2118
- ./cc-test-reporter before-build
2219
script:
23-
- . venv/bin/activate; coverage run -m unittest discover
20+
- make test-docker
2421
after_script:
22+
- make test-install
2523
- . venv/bin/activate; codecov
2624
- ./cc-test-reporter after-build --exit-code $?
2725
deploy:
@@ -32,7 +30,7 @@ deploy:
3230
distributions: sdist bdist_wheel
3331
on:
3432
tags: true
35-
python: '3.6'
33+
condition: $version=3.6
3634

3735
notifications:
3836
slack:

Dockerfile

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
ARG version=latest
2+
FROM python:$version
3+
4+
RUN pip install virtualenv
5+
6+
COPY prism/prism/nginx/cert.crt /usr/local/share/ca-certificates/cert.crt
7+
RUN update-ca-certificates
8+
9+
WORKDIR /app
10+
COPY . .
11+
12+
RUN make install

Makefile

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: venv install test-install test clean nopyc
1+
.PHONY: venv install test-install test test-integ test-docker clean nopyc
22

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

11-
test-install:
11+
test-install: install
1212
. venv/bin/activate; pip install -r test/requirements.txt
1313

1414
test: test-install
15-
./test/prism.sh &
16-
sleep 2
17-
. venv/bin/activate; python -m unittest discover -v
15+
16+
test-integ: test
17+
. venv/bin/activate; coverage run -m unittest discover
18+
19+
version ?= latest
20+
test-docker:
21+
curl -s https://raw.githubusercontent.com/sendgrid/sendgrid-oai/master/prism/prism.sh | version=$(version) bash
1822

1923
clean: nopyc
2024
rm -rf venv

test/prism.sh

-58
This file was deleted.

test/test_sendgrid.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,15 @@
55
import sendgrid
66
from sendgrid.helpers.endpoints.ip.unassigned import unassigned
77

8-
host = "http://localhost:4010"
9-
108

119
class UnitTests(unittest.TestCase):
1210

1311
@classmethod
1412
def setUpClass(cls):
15-
cls.host = host
1613
cls.path = '{}{}'.format(
1714
os.path.abspath(
1815
os.path.dirname(__file__)), '/..')
19-
cls.sg = sendgrid.SendGridAPIClient(host=host)
16+
cls.sg = sendgrid.SendGridAPIClient()
2017
cls.devnull = open(os.devnull, 'w')
2118

2219
def test_api_key_init(self):
@@ -34,7 +31,6 @@ def test_api_key_setter(self):
3431
def test_impersonate_subuser_init(self):
3532
temp_subuser = '[email protected]'
3633
sg_impersonate = sendgrid.SendGridAPIClient(
37-
host=host,
3834
impersonate_subuser=temp_subuser)
3935
self.assertEqual(sg_impersonate.impersonate_subuser, temp_subuser)
4036

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

4541
def test_host(self):
46-
self.assertEqual(self.sg.host, self.host)
42+
self.assertEqual(self.sg.host, 'https://api.sendgrid.com')
4743

4844
def test_get_default_headers(self):
4945
headers = self.sg._default_headers

0 commit comments

Comments
 (0)