Skip to content

Commit

Permalink
Switch from Mocks to VCR for more accurate test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
sethmlarson authored Jun 23, 2020
1 parent 7748f21 commit 0680ce7
Show file tree
Hide file tree
Showing 29 changed files with 594 additions and 295 deletions.
5 changes: 3 additions & 2 deletions .ci/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ services:
- "cluster.name=ent-search-docker-cluster"
- "bootstrap.memory_lock=true"
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "xpack.license.self_generated.type=trial"
- "xpack.security.enabled=true"
- "xpack.security.authc.api_key.enabled=true"
- "ELASTIC_PASSWORD=changeme"
Expand All @@ -26,7 +27,7 @@ services:
environment:
- "ENT_SEARCH_DEFAULT_PASSWORD=itsnotcloudsearch"
- "ent_search.listen_port=8080"
- "ent_search.external_url=http://enterprise-search:8080"
- "ent_search.external_url=http://localhost:8080"
- "ent_search.auth.source=standard"
- "elasticsearch.host=http://elasticsearch:9200"
- "allow_es_settings_modification=true"
Expand All @@ -38,4 +39,4 @@ services:
- 8081:8081
depends_on:
- elasticsearch
entrypoint: /bin/bash -c "until curl -s -f -u elastic:changeme elasticsearch:9200/_license|grep -q basic; do sleep 2; done; /usr/local/bin/docker-entrypoint.sh"
entrypoint: /bin/bash -c "until curl -s -f -u elastic:changeme elasticsearch:9200/_license|grep -q trial; do sleep 2; done; /usr/local/bin/docker-entrypoint.sh"
8 changes: 2 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [2.7, 3.4, 3.5, 3.6, 3.7, 3.8]
python-version: [2.7, 3.5, 3.6, 3.7, 3.8]

runs-on: ubuntu-latest
steps:
Expand All @@ -29,14 +29,10 @@ jobs:
- uses: actions/setup-python@v1
with:
python-version: 3.7
- if: matrix.python-version != '3.4' && matrix.python-version != '3.7'
- if: matrix.python-version != '3.7'
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- if: matrix.python-version == '3.4'
uses: deadsnakes/action@v1.0.0
with:
python-version: ${{ matrix.python-version }}

# Setup Enterprise Search
- name: Configure sysctl limits
Expand Down
3 changes: 3 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mock
pytest
pytest-recording
6 changes: 4 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@

@nox.session(python=["2.7", "3.4", "3.5", "3.6", "3.7", "3.8"])
def test(session):
session.install(".", "pytest", "mock")
session.run("pytest")
session.install(".")
session.install("-r", "dev-requirements.txt")

session.run("pytest", "--record-mode=none", "tests/")


@nox.session()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
interactions:
- request:
body: '[1, "2"]'
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Authorization:
- Bearer 32744aeb04f1269f57376347ee1d8f4e915e8273bfa9b2036aff4ef770bd2377
Connection:
- keep-alive
Content-Length:
- '8'
Content-Type:
- application/json
method: POST
uri: http://localhost:8080/api/ws/v1/sources/5eebbb1e5e21d6c1e64f9578/documents/bulk_destroy
response:
body:
string: '{"results":[{"id":1,"success":true},{"id":"2","success":true}]}'
headers:
Cache-Control:
- max-age=0, private, must-revalidate
Content-Type:
- application/json; charset=utf-8
ETag:
- W/"77b44f941fd70bd4db8769a374c4408d"
Server:
- Jetty(9.2.29.v20191105)
Transfer-Encoding:
- chunked
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- SAMEORIGIN
X-Request-Id:
- 95ce13bc-5e1d-46f1-aaca-6858d1d310c6
X-Runtime:
- '0.164300'
X-XSS-Protection:
- 1; mode=block
status:
code: 200
message: OK
version: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
interactions:
- request:
body: '[1, 2]'
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Authorization:
- Bearer 32744aeb04f1269f57376347ee1d8f4e915e8273bfa9b2036aff4ef770bd2377
Connection:
- keep-alive
Content-Length:
- '6'
Content-Type:
- application/json
method: POST
uri: http://localhost:8080/api/ws/v1/sources/bad-source-key/documents/bulk_destroy
response:
body:
string: ''
headers:
Cache-Control:
- no-cache
Content-Security-Policy:
- script-src 'nonce-L6XvPcXkNl85q8Wwyr0rVw==' 'strict-dynamic' 'self'; object-src
'none'; base-uri 'none'; frame-ancestors 'self';
Content-Type:
- text/html
Server:
- Jetty(9.2.29.v20191105)
Transfer-Encoding:
- chunked
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- SAMEORIGIN
X-Request-Id:
- 3e12a641-e82d-4639-8816-8dfa123d2200
X-Runtime:
- '0.020764'
X-XSS-Protection:
- 1; mode=block
status:
code: 404
message: Not Found
version: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
interactions:
- request:
body: '[{"id": 1, "url": "", "title": "", "body": ""}, {"id": "2", "url": "",
"title": "", "body": ""}]'
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Authorization:
- Bearer 32744aeb04f1269f57376347ee1d8f4e915e8273bfa9b2036aff4ef770bd2377
Connection:
- keep-alive
Content-Length:
- '96'
Content-Type:
- application/json
method: POST
uri: http://localhost:8080/api/ws/v1/sources/5eebbb1e5e21d6c1e64f9578/documents/bulk_create
response:
body:
string: '{"results":[{"id":"1","errors":[]},{"id":"2","errors":[]}]}'
headers:
Cache-Control:
- max-age=0, private, must-revalidate
Content-Type:
- application/json; charset=utf-8
ETag:
- W/"524357b5bfe8f3cf4539eab2daa660ff"
Server:
- Jetty(9.2.29.v20191105)
Transfer-Encoding:
- chunked
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- SAMEORIGIN
X-Request-Id:
- 279c7794-35e5-47ad-a5e0-3228fd8e031d
X-Runtime:
- '0.147254'
X-XSS-Protection:
- 1; mode=block
status:
code: 200
message: OK
version: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
interactions:
- request:
body: '[1, 2]'
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Authorization:
- Bearer 32744aeb04f1269f57376347ee1d8f4e915e8273bfa9b2036aff4ef770bd2377
Connection:
- keep-alive
Content-Length:
- '6'
Content-Type:
- application/json
method: POST
uri: http://localhost:8080/api/ws/v1/sources/bad-source-key/documents/bulk_create
response:
body:
string: ''
headers:
Cache-Control:
- no-cache
Content-Security-Policy:
- script-src 'nonce-e+nsspLfDiVaIGU5HixHxA==' 'strict-dynamic' 'self'; object-src
'none'; base-uri 'none'; frame-ancestors 'self';
Content-Type:
- text/html
Server:
- Jetty(9.2.29.v20191105)
Transfer-Encoding:
- chunked
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- SAMEORIGIN
X-Request-Id:
- 81b28e5a-56c3-46e3-820a-8e6238361ca6
X-Runtime:
- '0.036074'
X-XSS-Protection:
- 1; mode=block
status:
code: 404
message: Not Found
version: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
interactions:
- request:
body: '{"permissions": ["permission1"]}'
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Authorization:
- Bearer 32744aeb04f1269f57376347ee1d8f4e915e8273bfa9b2036aff4ef770bd2377
Connection:
- keep-alive
Content-Length:
- '32'
Content-Type:
- application/json
method: POST
uri: http://localhost:8080/api/ws/v1/sources/5eebbb1e5e21d6c1e64f9578/permissions/enterprise_search/add
response:
body:
string: '{"user":"enterprise_search","permissions":["permission1"]}'
headers:
Cache-Control:
- max-age=0, private, must-revalidate
Content-Type:
- application/json; charset=utf-8
ETag:
- W/"6cb0d74ff26d6f74253df3ee283a38dd"
Server:
- Jetty(9.2.29.v20191105)
Transfer-Encoding:
- chunked
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- SAMEORIGIN
X-Request-Id:
- 6cee13b3-2f2c-4983-9b35-cbe1825b9043
X-Runtime:
- '0.061162'
X-XSS-Protection:
- 1; mode=block
status:
code: 200
message: OK
version: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
interactions:
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Authorization:
- Bearer 32744aeb04f1269f57376347ee1d8f4e915e8273bfa9b2036aff4ef770bd2377
Connection:
- keep-alive
method: GET
uri: http://localhost:8080/api/ws/v1/sources/5eebbb1e5e21d6c1e64f9578/permissions/enterprise_search
response:
body:
string: '{"user":"enterprise_search","permissions":["permission1"]}'
headers:
Cache-Control:
- max-age=0, private, must-revalidate
Content-Type:
- application/json; charset=utf-8
ETag:
- W/"6cb0d74ff26d6f74253df3ee283a38dd"
Server:
- Jetty(9.2.29.v20191105)
Transfer-Encoding:
- chunked
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- SAMEORIGIN
X-Request-Id:
- bd1e3517-4395-4399-980f-b8dcfd883491
X-Runtime:
- '0.040057'
X-XSS-Protection:
- 1; mode=block
status:
code: 200
message: OK
version: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
interactions:
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Authorization:
- Bearer 32744aeb04f1269f57376347ee1d8f4e915e8273bfa9b2036aff4ef770bd2377
Connection:
- keep-alive
method: GET
uri: http://localhost:8080/api/ws/v1/sources/5eebbb1e5e21d6c1e64f9578/permissions?page%5Bcurrent%5D=1&page%5Bsize%5D=25
response:
body:
string: '{"meta":{"page":{"current":1,"total_pages":1,"total_results":1,"size":25}},"results":[{"user":"enterprise_search","permissions":["permission1"]}]}'
headers:
Cache-Control:
- max-age=0, private, must-revalidate
Content-Type:
- application/json; charset=utf-8
ETag:
- W/"21372cc57fbf7b6f6d19643937e4eaaf"
Server:
- Jetty(9.2.29.v20191105)
Transfer-Encoding:
- chunked
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- SAMEORIGIN
X-Request-Id:
- 7225d807-7a02-4322-a48a-6c05669c3eb6
X-Runtime:
- '0.041343'
X-XSS-Protection:
- 1; mode=block
status:
code: 200
message: OK
version: 1
Loading

0 comments on commit 0680ce7

Please sign in to comment.