smart-on-fhir / Swift-SMART

Swift SMART on FHIR framework for iOS and OS X
Other
135 stars 47 forks source link

Using Client class in XCTest #1

Open chh51 opened 8 years ago

chh51 commented 8 years ago

I need to run some Xcode unit tests based on the XCTest class. In SMART_on_FHIR_iOSTests.swift you have a simple example

class ClientTests: XCTestCase {

    func testInit() {
        let client = Client(baseURL: "https://api.io", settings: ["cliend_id": "client", "redirect": "oauth://callback"])
        XCTAssertTrue(client.server.baseURL.absoluteString == "https://api.io/")

//      //XCTAssertNil(client.auth.clientId, "clientId will only be queryable once we have an OAuth2 instance")
        client.ready { error in
            XCTAssertNil(error)
        }
    }
}

I notice that the client_id parameter is misspelled to cliend_id. Is this intentional ?

Can this be used to test against one of the SMART-on-FHIR test servers such as fhir-open-api-dstu2.smarthealthit.org ?

If so, what would the input settings to Client init( baseURL:, settings:, title: ) be ?

p2 commented 8 years ago

Nice catch, and not intentional; shows the desolate state the SMART specific test cases are in! The instruction to wait for the block callback is also missing, I don't think this test class is any good.

Yes, you can use the client to connect to the open FHIR endpoint. I haven't tried it in unit tests and am using a mock server in the other test cases, testing metadata parsing. Maybe that's a better approach for unit testing? What do you need to test?

chh51 commented 8 years ago

Well, my goal is to test many of the SMART-on-FIHR apis ( with some of my wrapper code around them ) in XCTests against the Smart, Cerner, and Epic test servers.

I need automated tests so that I can run regression tests every day or so to make sure I am not breaking something.

This describes what I am trying to do http://e2.edgemoor.com/doc/s16s3.html http://e2.edgemoor.com/doc/s16s3.html

Chris Hawkins dev98029@icloud.com

On Apr 21, 2016, at 1:08 PM, Pascal Pfiffner notifications@github.com wrote:

Nice catch, and not intentional; shows the desolate state the SMART specific test cases are in! The instruction to wait for the block callback is also missing, I don't think this test class is any good.

Yes, you can use the client to connect to the open FHIR endpoint. I haven't tried it in unit tests and am using a mock server in the other test cases https://github.com/smart-on-fhir/Swift-SMART/blob/master/Tests/ServerTests.swift#L33, testing metadata parsing. Maybe that's a better approach for unit testing? What do you need to test?

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/smart-on-fhir/Swift-SMART/issues/1#issuecomment-213094323

p2 commented 8 years ago

Ah great! Yes, that makes sense. The client works by reading the Conformance statement the first time any REST call is needed, so for open servers you may only need to specify baseURL and an empty settings dictionary on Client.init.

Let me know how it goes!

chh51 commented 8 years ago

I hope to be working on that by tomorrow, will let you know how it works out.

On Apr 21, 2016, at 1:20 PM, Pascal Pfiffner notifications@github.com wrote:

Ah great! Yes, that makes sense. The client works by reading the Conformance statement the first time any REST call is needed, so for open servers you may only need to specify baseURL and an empty settings dictionary on Client.init.

Let me know how it goes!

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/smart-on-fhir/Swift-SMART/issues/1#issuecomment-213099072