Skip to content

Commit

Permalink
Fix a previously skipped test (#209)
Browse files Browse the repository at this point in the history
What:
- Fix a previously skipped test

Why:
- Prove that #112 is truly fixed
  • Loading branch information
komuw authored Jun 1, 2020
1 parent ccabab3 commit 8b1ec3d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
most recent version is listed first.


## **version:** v0.8.1
- Fix a previously skipped test: https://github.com/komuw/naz/pull/209


## **version:** v0.8.0
- Bugfix - RuntimeError: Cannot call `write()` after `write_eof()`: https://github.com/komuw/naz/pull/208
- support Smpp Optional Tags in `submit_sm`: https://github.com/komuw/naz/pull/202, https://github.com/komuw/naz/pull/207
Expand Down
16 changes: 10 additions & 6 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import codecs
import struct
import asyncio
from unittest import TestCase, mock, skip
from unittest import TestCase, mock

import naz
import docker
Expand Down Expand Up @@ -866,22 +866,26 @@ def test_issues_67(self):
)
self.assertTrue(mock_naz_tranceiver_bind.mock.called)

@skip("TODO:fix this. It does not work.")
def test_issues_112(self):
"""
test to prove we have fixed: https://github.com/komuw/naz/issues/112
Run `Client.enquire_link`. Check if `StreamWriter.write` was called twice(one for `tranceiver_bind` and another for `enquire_link`)
If `StreamWriter.write` was called, it means that our `enquire_link` call didnt get a:
enquire_link cannot be sent to SMSC when the client session state is: OPEN error.
Run `Client.enquire_link`.
Check if `StreamWriter.write` was called twice(one for `tranceiver_bind` and another for `enquire_link`)
"""
with mock.patch("asyncio.streams.StreamWriter.write") as mock_naz_writer:
self._run(self.cli.connect())
self._run(self.cli.tranceiver_bind())
# self.cli.current_session_state = naz.SmppSessionState.BOUND_TRX
for item in (self.cli.system_id, self.cli.password):
# system_id & password are only sent in `tranceiver_bind`
self.assertIn(item.encode("ascii"), mock_naz_writer.call_args[0][0])

self._run(self.cli.enquire_link(TESTING=True))
self.assertTrue(mock_naz_writer.called)
self.assertEqual(mock_naz_writer.call_count, 2)
# assert `enquire_link` command_id is in the sent data
_command_id = struct.pack(">I", self.cli.command_ids["enquire_link"])
self.assertIn(_command_id, mock_naz_writer.call_args[0][0])

def test_command_id_lookup(self):
command_id = self.cli._search_by_command_id_code(
Expand Down

0 comments on commit 8b1ec3d

Please sign in to comment.