Created
June 8, 2014 20:50
-
-
Save eferro/11fd8352d5defdeee3c9 to your computer and use it in GitHub Desktop.
spec example using mamba
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with description('CPE status'): | |
with before.each: | |
self.ppg_service = Stub(ppg_services.ProductPackageGroupService) | |
self.sip_credentials = Stub(sip_credentials_module.SipCredentials) | |
self.cpe_status_repository = InMemoryCPEStatusRepository() | |
self.cpe_status_event_history_repository = InMemoryCPEStatusEventHistoryRepository() | |
self.clock = Stub(clock.Clock) | |
self.cpe_status_service = cpe_status_service(self.cpe_status_repository, | |
self.ppg_service, | |
self.sip_credentials, | |
self.cpe_status_event_history_repository, | |
self.clock) | |
with context('when cpe goes online'): | |
with it('registers the cpe status'): | |
self._put_cpe_online(IRRELEVANT_CPE_ID) | |
cpe_status = self._cpe_status_by(IRRELEVANT_CPE_ID) | |
assert_that(cpe_status.online, is_(True)) | |
with context('when cpe goes offline'): | |
with description('with registered voip lines'): | |
with before.each: | |
self._put_cpe_online(IRRELEVANT_CPE_ID) | |
self._register_voip_line(IRRELEVANT_CPE_ID) | |
with it('registers the status and discards voip status'): | |
self._put_cpe_offline(IRRELEVANT_CPE_ID) | |
cpe_status = self._cpe_status_by(IRRELEVANT_CPE_ID) | |
assert_that(cpe_status.online, is_(False)) | |
self._expect_voip_status_is_discarded(cpe_status) | |
def _expect_voip_status_is_discarded(self, cpe_status): | |
assert_that(cpe_status.voip_online(CLI_INDEX), is_(False)) | |
assert_that(cpe_status.voip_idle(CLI_INDEX), is_(True)) | |
with description('with extended status'): | |
with it('registers the status and discards extended status'): | |
self._an_extended_status_event(_make_a_measure('measure1', value=1)) | |
self._put_cpe_offline(IRRELEVANT_CPE_ID) | |
cpe_status = self._cpe_status_by(IRRELEVANT_CPE_ID) | |
assert_that(cpe_status.online, is_(False)) | |
assert_that(cpe_status.has_extended_status(), is_(False)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment