test/efax_outbound_test.rb in efax-1.3.2 vs test/efax_outbound_test.rb in efax-1.3.3

- old
+ new

@@ -58,11 +58,11 @@ </Transmission> </OutboundResponse> XML http_response = mock() http_response.expects(:is_a?).with(Net::HTTPOK).returns(true) - http_response.expects(:body).returns(xml) + http_response.expects(:body).returns(xml) response = EFax::OutboundResponse.new(http_response) assert_equal EFax::RequestStatus::FAILURE, response.status_code assert_nil response.doc_id assert_equal "We FAIL", response.error_message assert_equal "System", response.error_level @@ -86,11 +86,11 @@ </Transmission> </OutboundResponse> XML http_response = mock() http_response.expects(:is_a?).with(Net::HTTPOK).returns(true) - http_response.expects(:body).returns(xml) + http_response.expects(:body).returns(xml) response = EFax::OutboundResponse.new(http_response) assert_equal EFax::RequestStatus::FAILURE, response.status_code assert_nil response.doc_id assert_equal '"QWE RTY" does not satisfy the "base64Binary" type', response.error_message assert_equal "User", response.error_level @@ -149,18 +149,70 @@ </Transmission> </OutboundStatusResponse> XML http_response = mock() http_response.expects(:is_a?).with(Net::HTTPOK).returns(true) - http_response.expects(:body).returns(xml) + http_response.expects(:body).returns(xml) response = EFax::OutboundStatusResponse.new(http_response) assert_equal "Your transmission has completed.", response.message assert_equal "Success", response.outcome assert_equal "Success", response.classification assert_equal EFax::QueryStatus::SENT, response.status_code end + def test_busy_response + xml = <<-XML + <?xml version="1.0"?> + <OutboundStatusResponse> + <Transmission> + <TransmissionControl> + <TransmissionID></TransmissionID> + </TransmissionControl> + <Recipients> + <Recipient> + <DOCID>12345678</DOCID> + <Name>Mike Rotch</Name> + <Company>Moe's</Company> + <Fax>12345678901</Fax> + <Status> + <Message>Your transmission is waiting to be sent.</Message> + <Classification>Busy</Classification> + <Outcome>Normal busy: remote end busy (off hook)</Outcome> + </Status> + <LastAttempt> + <LastDate></LastDate> + <LastTime></LastTime> + </LastAttempt> + <NextAttempt> + <NextDate></NextDate> + <NextTime></NextTime> + </NextAttempt> + <Pages> + <Scheduled>1</Scheduled> + <Sent>1</Sent> + </Pages> + <BaudRate>14400</BaudRate> + <Duration>0.4</Duration> + <Retries>1</Retries> + <RemoteCSID>"-"</RemoteCSID> + </Recipient> + </Recipients> + </Transmission> + </OutboundStatusResponse> + XML + + http_response = mock() + http_response.expects(:is_a?).with(Net::HTTPOK).returns(true) + http_response.expects(:body).returns(xml) + response = EFax::OutboundStatusResponse.new(http_response) + + assert_equal "Normal busy: remote end busy (off hook)", response.outcome + assert_equal "Busy", response.classification + assert_equal "Your transmission is waiting to be sent.", response.message + assert_equal EFax::QueryStatus::PENDING, response.status_code + end + def test_pending_response xml = <<-XML <?xml version="1.0"?> <OutboundStatusResponse> <Transmission> @@ -200,13 +252,13 @@ </OutboundStatusResponse> XML http_response = mock() http_response.expects(:is_a?).with(Net::HTTPOK).returns(true) - http_response.expects(:body).returns(xml) + http_response.expects(:body).returns(xml) response = EFax::OutboundStatusResponse.new(http_response) - + assert_equal "", response.outcome assert_equal "", response.classification assert_equal EFax::QueryStatus::PENDING, response.status_code end @@ -251,13 +303,13 @@ </OutboundStatusResponse> XML http_response = mock() http_response.expects(:is_a?).with(Net::HTTPOK).returns(true) - http_response.expects(:body).returns(xml) + http_response.expects(:body).returns(xml) response = EFax::OutboundStatusResponse.new(http_response) - + assert_equal "Your fax caused the world to end", response.message assert_equal "End of days", response.outcome assert_equal "Apocalyptic failure", response.classification assert_equal EFax::QueryStatus::FAILURE, response.status_code end @@ -327,32 +379,6 @@ EFax::OutboundStatus.publicize_class_methods do assert_equal expected_xml.delete(" "), EFax::OutboundStatus.xml("123456").delete(" ") end end end - - class OutboundStatusTest < Test::Unit::TestCase - def test_generate_xml - expected_xml = <<-XML - <?xml version="1.0" encoding="UTF-8"?> - <OutboundStatus> - <AccessControl> - <UserName>Mike Rotch</UserName> - <Password>moes</Password> - </AccessControl> - <Transmission> - <TransmissionControl> - <DOCID>123456</DOCID> - </TransmissionControl> - </Transmission> - </OutboundStatus> - XML - - EFax::Request.user = "Mike Rotch" - EFax::Request.password = "moes" - EFax::OutboundStatus.publicize_class_methods do - assert_equal expected_xml.delete(" "), EFax::OutboundStatus.xml("123456").delete(" ") - end - end - end - end