Skip to content

Commit

Permalink
Actually, I should be testing the send command and not overspecify in…
Browse files Browse the repository at this point in the history
…ner structure.
  • Loading branch information
Rachel Sanders committed Oct 20, 2014
1 parent a66059c commit c394dde
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@ def test_requesting_an_event_id_that_doest_exist_throws_error(self):
self.connection.send(b'yo')



@httpretty.activate
def test_connection_is_cached():

httpretty.register_uri(httpretty.POST, FAKE_EXCHANGE_URL,
status=200,
body="", )

manager = MagicMock()

with patch('pyexchange.connection.HttpNtlmAuth') as MockHttpNtlmAuth:
Expand All @@ -50,18 +54,21 @@ def test_connection_is_cached():
username=FAKE_EXCHANGE_USERNAME,
password=FAKE_EXCHANGE_PASSWORD)


connection.build_password_manager()
connection.build_password_manager()
connection.send("test")
connection.send("test again")

# assert we only get called once, after that it's cached
manager.MockHttpNtlmAuth.assert_called_once_with(FAKE_EXCHANGE_USERNAME, FAKE_EXCHANGE_PASSWORD)


@httpretty.activate
def test_session_is_cached():

manager = MagicMock()

httpretty.register_uri(httpretty.POST, FAKE_EXCHANGE_URL,
status=200,
body="", )

with patch('requests.Session') as MockSession:

manager.attach_mock(MockSession, 'MockSession')
Expand All @@ -70,9 +77,8 @@ def test_session_is_cached():
username=FAKE_EXCHANGE_USERNAME,
password=FAKE_EXCHANGE_PASSWORD)


connection.build_session()
connection.build_session()
connection.send("test")
connection.send("test again")

# assert we only get called once, after that it's cached
manager.MockSession.assert_called_once_with()

0 comments on commit c394dde

Please sign in to comment.