Skip to content

Commit

Permalink
Added diff report tests (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjjimenez committed Jul 9, 2020
1 parent 25d5874 commit c0152b9
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Tests/JobTests.swift
Expand Up @@ -21,6 +21,8 @@ class JobTests: XCTestCase {
var diffReportClient: SyftClient!
var diffReportJob: SyftJob!

var diffExpectation: XCTestExpectation!

override func setUp() {
// Put setup code here. This method is called before the invocation of each test method in the class.

Expand Down Expand Up @@ -65,6 +67,15 @@ class JobTests: XCTestCase {

}

stub(condition: isHost("test.com") && isPath("/federated/report")) { _ -> HTTPStubsResponse in

self.diffExpectation.fulfill()

return HTTPStubsResponse(data: Data(), statusCode: 200, headers: nil)

}


}

func testOneJobCompletes() {
Expand Down Expand Up @@ -124,6 +135,20 @@ class JobTests: XCTestCase {
// TODO: Wait for PyTorch fix to run in simulator: https://github.com/pytorch/pytorch/issues/32040
func testModelDiffReport() {

self.diffExpectation = XCTestExpectation(description: "Test if diff was reported")

self.diffReportClient = SyftClient(url: URL(string: "http://test.com:5000")!)!
self.diffReportJob = self.diffReportClient.newJob(modelName: "mnist", version: "1.0")

self.diffReportJob.onReady { (_, _, report) in

report(Data())

}

self.diffReportJob.start(chargeDetection: false, wifiDetection: false)

wait(for: [self.diffExpectation], timeout: 7)
}

override func tearDown() {
Expand Down

0 comments on commit c0152b9

Please sign in to comment.