Skip to content

Commit 5419075

Browse files
Daniel Abrahamcopybara-github
authored andcommitted
Unit tests for the v1 samples. Also replace (unused?) Travis config with GitHub Actions.
PiperOrigin-RevId: 342075553
1 parent ff4473d commit 5419075

25 files changed

Lines changed: 627 additions & 29 deletions

.github/workflows/python-app.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Python application
5+
6+
on:
7+
push:
8+
branches: [ master ]
9+
pull_request:
10+
branches: [ master ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Set up Python 3.8
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: 3.8
23+
- name: Install dependencies
24+
run: |
25+
python -m pip install --upgrade pip
26+
pip install flake8 pytest
27+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
28+
- name: Lint with flake8
29+
run: |
30+
# stop the build if there are Python syntax errors or undefined names
31+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
32+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
33+
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
34+
- name: Test with pytest
35+
run: |
36+
python -m pytest

.travis.yml

Lines changed: 0 additions & 7 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@ directory of this repository (i.e. the directory which contains this `README.md`
4747
file):
4848

4949
```shell
50-
./samples/v1/<sample_name>.py -h
50+
python3 -m samples.v1.<sample_name> -h
5151
```

samples/v1/cancel_operation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import argparse
2020
import re
2121

22-
import chronicle_auth
22+
from . import chronicle_auth
2323
from google.auth.transport import requests
2424

2525
CHRONICLE_API_BASE_URL = "https://backstory.googleapis.com"

samples/v1/create_rule.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import argparse
2020

21-
import chronicle_auth
21+
from . import chronicle_auth
2222
from google.auth.transport import requests
2323

2424
CHRONICLE_API_BASE_URL = "https://backstory.googleapis.com"

samples/v1/delete_operation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import argparse
2020
import re
2121

22-
import chronicle_auth
22+
from . import chronicle_auth
2323
from google.auth.transport import requests
2424

2525
CHRONICLE_API_BASE_URL = "https://backstory.googleapis.com"

samples/v1/delete_rule.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import argparse
2020
import re
2121

22-
import chronicle_auth
22+
from . import chronicle_auth
2323
from google.auth.transport import requests
2424

2525
CHRONICLE_API_BASE_URL = "https://backstory.googleapis.com"

samples/v1/enable_live_rule.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import argparse
2020
import re
2121

22-
import chronicle_auth
22+
from . import chronicle_auth
2323
from google.auth.transport import requests
2424

2525
CHRONICLE_API_BASE_URL = "https://backstory.googleapis.com"

samples/v1/get_operation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from typing import Optional
2323

2424
import dataclasses
25-
import chronicle_auth
25+
from . import chronicle_auth
2626
from google.auth.transport import requests
2727

2828
CHRONICLE_API_BASE_URL = "https://backstory.googleapis.com"

samples/v1/get_rule.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import argparse
2020
import re
2121

22-
import chronicle_auth
22+
from . import chronicle_auth
2323
from google.auth.transport import requests
2424

2525
CHRONICLE_API_BASE_URL = "https://backstory.googleapis.com"

0 commit comments

Comments
 (0)