Skip to content

Commit

Permalink
Add github workflow for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tochev committed Apr 5, 2024
1 parent 16bf03b commit f929ffe
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 1 deletion.
29 changes: 29 additions & 0 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Push Workflow

on: push

jobs:
run_tests:
name: Run Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Requirements
run: pip install -r door_ivr/requirements.txt
- name: Run tests
working-directory: door_ivr/tests/
timeout-minutes: 1
run: >
python backend_mock.py &
sleep 1 &&
echo "=== TEST RUN NORMAL ===" &&
./run-test.sh agi-test.txt 2>&1 | tee agi-test-result.txt &&
echo "=== TEST UNKNOWN NUMBER ===" &&
./run-test.sh agi-unknown-number.txt 2>&1 | tee agi-test-unknown-number-result.txt
- name: Compare results
working-directory: door_ivr/tests/
run: >
echo "=== COMPARE RUN NORMAL ===" &&
diff -U 3 agi-test-expected.txt agi-test-result.txt &&
echo "=== COMPARE UNKNOWN NUMBER ===" &&
diff -U 3 agi-test-unknown-number-expected.txt agi-test-unknown-number-result.txt
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ service asterisk restart
## Testing

```
cd door_ivr/door_ivr/
cd door_ivr/tests/
python backend_mock.py &
./run-test.sh agi-test.txt
./run-test.sh agi-unknown-number.txt
Expand Down
96 changes: 96 additions & 0 deletions door_ivr/tests/agi-test-expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
ARGS: ['../door_ivr.py', '--handler=external', '--config=../door_ivr.test.conf']
ENV LINE: agi_callerid: 0881234567
ENV LINE:
class AGI: self.env = {'agi_callerid': '0881234567'}
COMMAND: VERBOSE "External phone door IVR received a call from '0881234567'" 1
VERBOSE "External phone door IVR received a call from '0881234567'" 1
RESULT_LINE: 200 result=1
RESULT_DICT: {'result': ('1', '')}
COMMAND: ANSWER
ANSWER
RESULT_LINE: 200 result=0
RESULT_DICT: {'result': ('0', '')}
COMMAND: STREAM FILE /home/runner/work/initlab-telephony/initlab-telephony/door_ivr/tests/initlab-telephony-assets/files/bg/welcome "0123456789" 0
STREAM FILE /home/runner/work/initlab-telephony/initlab-telephony/door_ivr/tests/initlab-telephony-assets/files/bg/welcome "0123456789" 0
RESULT_LINE: 200 result=0
RESULT_DICT: {'result': ('0', '')}
COMMAND: STREAM FILE /home/runner/work/initlab-telephony/initlab-telephony/door_ivr/tests/initlab-telephony-assets/files/bg/enter_pin "0123456789" 0
STREAM FILE /home/runner/work/initlab-telephony/initlab-telephony/door_ivr/tests/initlab-telephony-assets/files/bg/enter_pin "0123456789" 0
RESULT_LINE: 200 result=0
RESULT_DICT: {'result': ('0', '')}
COMMAND: WAIT FOR DIGIT 12000
WAIT FOR DIGIT 12000
RESULT_LINE: 200 result=49
RESULT_DICT: {'result': ('49', '')}
COMMAND: WAIT FOR DIGIT 4000
WAIT FOR DIGIT 4000
RESULT_LINE: 200 result=50
RESULT_DICT: {'result': ('50', '')}
COMMAND: WAIT FOR DIGIT 4000
WAIT FOR DIGIT 4000
RESULT_LINE: 200 result=51
RESULT_DICT: {'result': ('51', '')}
COMMAND: WAIT FOR DIGIT 4000
WAIT FOR DIGIT 4000
RESULT_LINE: 200 result=52
RESULT_DICT: {'result': ('52', '')}
COMMAND: WAIT FOR DIGIT 4000
WAIT FOR DIGIT 4000
RESULT_LINE: 200 result=53
RESULT_DICT: {'result': ('53', '')}
COMMAND: WAIT FOR DIGIT 4000
WAIT FOR DIGIT 4000
RESULT_LINE: 200 result=54
RESULT_DICT: {'result': ('54', '')}
COMMAND: WAIT FOR DIGIT 4000
WAIT FOR DIGIT 4000
RESULT_LINE: 200 result=35
RESULT_DICT: {'result': ('35', '')}
COMMAND: STREAM FILE /home/runner/work/initlab-telephony/initlab-telephony/door_ivr/tests/initlab-telephony-assets/files/bg/door_prompt_1 "1239" 0
STREAM FILE /home/runner/work/initlab-telephony/initlab-telephony/door_ivr/tests/initlab-telephony-assets/files/bg/door_prompt_1 "1239" 0
RESULT_LINE: 200 result=49
RESULT_DICT: {'result': ('49', '')}
COMMAND: STREAM FILE /home/runner/work/initlab-telephony/initlab-telephony/door_ivr/tests/initlab-telephony-assets/files/bg/door_opened_1 "" 0
STREAM FILE /home/runner/work/initlab-telephony/initlab-telephony/door_ivr/tests/initlab-telephony-assets/files/bg/door_opened_1 "" 0
RESULT_LINE: 200 result=0
RESULT_DICT: {'result': ('0', '')}
COMMAND: STREAM FILE /home/runner/work/initlab-telephony/initlab-telephony/door_ivr/tests/initlab-telephony-assets/files/bg/door_prompt_1 "1239" 0
STREAM FILE /home/runner/work/initlab-telephony/initlab-telephony/door_ivr/tests/initlab-telephony-assets/files/bg/door_prompt_1 "1239" 0
RESULT_LINE: 200 result=0
RESULT_DICT: {'result': ('0', '')}
COMMAND: STREAM FILE /home/runner/work/initlab-telephony/initlab-telephony/door_ivr/tests/initlab-telephony-assets/files/bg/door_prompt_2 "1239" 0
STREAM FILE /home/runner/work/initlab-telephony/initlab-telephony/door_ivr/tests/initlab-telephony-assets/files/bg/door_prompt_2 "1239" 0
RESULT_LINE: 200 result=0
RESULT_DICT: {'result': ('0', '')}
COMMAND: STREAM FILE /home/runner/work/initlab-telephony/initlab-telephony/door_ivr/tests/initlab-telephony-assets/files/bg/door_prompt_3 "1239" 0
STREAM FILE /home/runner/work/initlab-telephony/initlab-telephony/door_ivr/tests/initlab-telephony-assets/files/bg/door_prompt_3 "1239" 0
RESULT_LINE: 200 result=50
RESULT_DICT: {'result': ('50', '')}
COMMAND: STREAM FILE /home/runner/work/initlab-telephony/initlab-telephony/door_ivr/tests/initlab-telephony-assets/files/bg/door_opened_2 "" 0
STREAM FILE /home/runner/work/initlab-telephony/initlab-telephony/door_ivr/tests/initlab-telephony-assets/files/bg/door_opened_2 "" 0
RESULT_LINE: 200 result=0
RESULT_DICT: {'result': ('0', '')}
COMMAND: STREAM FILE /home/runner/work/initlab-telephony/initlab-telephony/door_ivr/tests/initlab-telephony-assets/files/bg/door_prompt_1 "1239" 0
STREAM FILE /home/runner/work/initlab-telephony/initlab-telephony/door_ivr/tests/initlab-telephony-assets/files/bg/door_prompt_1 "1239" 0
RESULT_LINE: 200 result=0
RESULT_DICT: {'result': ('0', '')}
COMMAND: STREAM FILE /home/runner/work/initlab-telephony/initlab-telephony/door_ivr/tests/initlab-telephony-assets/files/bg/door_prompt_2 "1239" 0
STREAM FILE /home/runner/work/initlab-telephony/initlab-telephony/door_ivr/tests/initlab-telephony-assets/files/bg/door_prompt_2 "1239" 0
RESULT_LINE: 200 result=0
RESULT_DICT: {'result': ('0', '')}
COMMAND: STREAM FILE /home/runner/work/initlab-telephony/initlab-telephony/door_ivr/tests/initlab-telephony-assets/files/bg/door_prompt_3 "1239" 0
STREAM FILE /home/runner/work/initlab-telephony/initlab-telephony/door_ivr/tests/initlab-telephony-assets/files/bg/door_prompt_3 "1239" 0
RESULT_LINE: 200 result=57
RESULT_DICT: {'result': ('57', '')}
COMMAND: STREAM FILE /home/runner/work/initlab-telephony/initlab-telephony/door_ivr/tests/initlab-telephony-assets/files/bg/door_locked "" 0
STREAM FILE /home/runner/work/initlab-telephony/initlab-telephony/door_ivr/tests/initlab-telephony-assets/files/bg/door_locked "" 0
RESULT_LINE: 200 result=0
RESULT_DICT: {'result': ('0', '')}
COMMAND: STREAM FILE /home/runner/work/initlab-telephony/initlab-telephony/door_ivr/tests/initlab-telephony-assets/files/bg/goodbye "" 0
STREAM FILE /home/runner/work/initlab-telephony/initlab-telephony/door_ivr/tests/initlab-telephony-assets/files/bg/goodbye "" 0
RESULT_LINE: 200 result=0
RESULT_DICT: {'result': ('0', '')}
COMMAND: HANGUP
HANGUP
RESULT_LINE: 200
RESULT_DICT: {'result': ('', '')}
32 changes: 32 additions & 0 deletions door_ivr/tests/agi-test-unknown-number-expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
ARGS: ['../door_ivr.py', '--handler=external', '--config=../door_ivr.test.conf']
ENV LINE: agi_callerid: +359880000000
ENV LINE:
class AGI: self.env = {'agi_callerid': '+359880000000'}
COMMAND: VERBOSE "External phone door IVR received a call from '+359880000000'" 1
VERBOSE "External phone door IVR received a call from '+359880000000'" 1
RESULT_LINE: 200
RESULT_DICT: {'result': ('', '')}
COMMAND: GET VARIABLE "FALLBACK_EXTENSION"
GET VARIABLE "FALLBACK_EXTENSION"
RESULT_LINE: 200
RESULT_DICT: {'result': ('', '')}
COMMAND: ANSWER
ANSWER
RESULT_LINE: 200
RESULT_DICT: {'result': ('', '')}
COMMAND: STREAM FILE /home/runner/work/initlab-telephony/initlab-telephony/door_ivr/tests/initlab-telephony-assets/files/bg/welcome "" 0
STREAM FILE /home/runner/work/initlab-telephony/initlab-telephony/door_ivr/tests/initlab-telephony-assets/files/bg/welcome "" 0
RESULT_LINE: 200 result=101
RESULT_DICT: {'result': ('101', '')}
COMMAND: STREAM FILE /home/runner/work/initlab-telephony/initlab-telephony/door_ivr/tests/initlab-telephony-assets/files/bg/redirecting_to_public_phone "" 0
STREAM FILE /home/runner/work/initlab-telephony/initlab-telephony/door_ivr/tests/initlab-telephony-assets/files/bg/redirecting_to_public_phone "" 0
RESULT_LINE: 200 result=0
RESULT_DICT: {'result': ('0', '')}
COMMAND: SET EXTENSION 1234
SET EXTENSION 1234
RESULT_LINE: 200
RESULT_DICT: {'result': ('', '')}
COMMAND: set priority 1
set priority 1
RESULT_LINE: 200
RESULT_DICT: {'result': ('', '')}
4 changes: 4 additions & 0 deletions door_ivr/tests/backend_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

class FaunaHandler(http.server.BaseHTTPRequestHandler):

def setup(self):
self.server.allow_reuse_address = True
super().setup()

def do_GET(self):
if self.path == '/api/doors':
self.send_response(http.HTTPStatus.OK)
Expand Down

0 comments on commit f929ffe

Please sign in to comment.