Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Device and Platforms tests #65

Merged
merged 9 commits into from
Jul 14, 2015
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions XcodeServerSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@
702706851B445F6A00E09FDF /* XcodeServer+SCM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 702706841B445F6A00E09FDF /* XcodeServer+SCM.swift */; };
702706861B445F6A00E09FDF /* XcodeServer+SCM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 702706841B445F6A00E09FDF /* XcodeServer+SCM.swift */; };
702706871B445F6A00E09FDF /* XcodeServer+SCM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 702706841B445F6A00E09FDF /* XcodeServer+SCM.swift */; };
703FED511B53AD1B00943876 /* DevicesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 703FED501B53AD1B00943876 /* DevicesTests.swift */; };
703FED521B53AD1B00943876 /* DevicesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 703FED501B53AD1B00943876 /* DevicesTests.swift */; };
7045917F1B4074CC00BA226C /* Repository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7045917E1B4074CC00BA226C /* Repository.swift */; };
704591861B40945700BA226C /* RepositoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 704591851B40945700BA226C /* RepositoryTests.swift */; };
704B5FC41B455EE400989E4B /* get_repositories.json in Resources */ = {isa = PBXBuildFile; fileRef = 704B5FC31B455EE400989E4B /* get_repositories.json */; };
Expand All @@ -123,6 +125,12 @@
707D089A1B2C6986003900F3 /* BotSchedule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 707D08991B2C6986003900F3 /* BotSchedule.swift */; };
707D089C1B2C69C4003900F3 /* Trigger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 707D089B1B2C69C4003900F3 /* Trigger.swift */; };
707D089E1B2C6A1F003900F3 /* TriggerConditions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 707D089D1B2C6A1F003900F3 /* TriggerConditions.swift */; };
7089CBB21B53BD06006C9EC5 /* get_devices.json in Resources */ = {isa = PBXBuildFile; fileRef = 7089CBB11B53BD06006C9EC5 /* get_devices.json */; };
7089CBB31B53BD06006C9EC5 /* get_devices.json in Resources */ = {isa = PBXBuildFile; fileRef = 7089CBB11B53BD06006C9EC5 /* get_devices.json */; };
7089CBB81B53DC9D006C9EC5 /* PlatformTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7089CBB71B53DC9D006C9EC5 /* PlatformTests.swift */; };
7089CBB91B53DC9D006C9EC5 /* PlatformTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7089CBB71B53DC9D006C9EC5 /* PlatformTests.swift */; };
7089CBBB1B53DD7A006C9EC5 /* get_platforms.json in Resources */ = {isa = PBXBuildFile; fileRef = 7089CBBA1B53DD7A006C9EC5 /* get_platforms.json */; };
7089CBBC1B53DD7A006C9EC5 /* get_platforms.json in Resources */ = {isa = PBXBuildFile; fileRef = 7089CBBA1B53DD7A006C9EC5 /* get_platforms.json */; };
709ED67C1B35FD3F00A06038 /* XcodeServerEntityTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 709ED67B1B35FD3F00A06038 /* XcodeServerEntityTests.swift */; };
709ED6801B3608FC00A06038 /* XcodeServerConfigTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 709ED67F1B3608FC00A06038 /* XcodeServerConfigTests.swift */; };
70A4448F1B457ACC00C86EF8 /* XcodeServer+Repository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70C2D8481B432A55008845FB /* XcodeServer+Repository.swift */; };
Expand Down Expand Up @@ -255,6 +263,7 @@
3ABE68651B3AC3C500FA0A61 /* DeviceSpecification.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeviceSpecification.swift; sourceTree = "<group>"; };
7027067D1B44548800E09FDF /* XcodeServer+Bot.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "XcodeServer+Bot.swift"; sourceTree = "<group>"; };
702706841B445F6A00E09FDF /* XcodeServer+SCM.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "XcodeServer+SCM.swift"; sourceTree = "<group>"; };
703FED501B53AD1B00943876 /* DevicesTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DevicesTests.swift; sourceTree = "<group>"; };
7045917E1B4074CC00BA226C /* Repository.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Repository.swift; sourceTree = "<group>"; };
704591851B40945700BA226C /* RepositoryTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RepositoryTests.swift; sourceTree = "<group>"; };
704B5FC31B455EE400989E4B /* get_repositories.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = get_repositories.json; sourceTree = "<group>"; };
Expand All @@ -264,6 +273,9 @@
707D08991B2C6986003900F3 /* BotSchedule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BotSchedule.swift; sourceTree = "<group>"; };
707D089B1B2C69C4003900F3 /* Trigger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Trigger.swift; sourceTree = "<group>"; };
707D089D1B2C6A1F003900F3 /* TriggerConditions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TriggerConditions.swift; sourceTree = "<group>"; };
7089CBB11B53BD06006C9EC5 /* get_devices.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = get_devices.json; sourceTree = "<group>"; };
7089CBB71B53DC9D006C9EC5 /* PlatformTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlatformTests.swift; sourceTree = "<group>"; };
7089CBBA1B53DD7A006C9EC5 /* get_platforms.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = get_platforms.json; sourceTree = "<group>"; };
709ED67B1B35FD3F00A06038 /* XcodeServerEntityTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XcodeServerEntityTests.swift; sourceTree = "<group>"; };
709ED67F1B3608FC00A06038 /* XcodeServerConfigTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XcodeServerConfigTests.swift; sourceTree = "<group>"; };
70B21FF71B3AFB1D00EAD4EB /* BotConfigurationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BotConfigurationTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -403,7 +415,9 @@
3A058A921B315BB50077FD47 /* TestUtils.swift */,
705D59A01B3AE502002521BA /* HTTPUtilsTests.swift */,
70B21FF71B3AFB1D00EAD4EB /* BotConfigurationTests.swift */,
703FED501B53AD1B00943876 /* DevicesTests.swift */,
704591851B40945700BA226C /* RepositoryTests.swift */,
7089CBB71B53DC9D006C9EC5 /* PlatformTests.swift */,
3A7B48CA1B2A5AC40077ABEA /* Supporting Files */,
);
path = XcodeServerSDKTests;
Expand Down Expand Up @@ -442,6 +456,8 @@
children = (
3A3853A11B4002C900B7F842 /* osx_bot.json */,
704B5FC31B455EE400989E4B /* get_repositories.json */,
7089CBB11B53BD06006C9EC5 /* get_devices.json */,
7089CBBA1B53DD7A006C9EC5 /* get_platforms.json */,
);
name = Casettes;
path = XcodeServerSDKTests/Casettes;
Expand Down Expand Up @@ -743,13 +759,15 @@
buildActionMask = 2147483647;
files = (
704B5FC51B455EE400989E4B /* get_repositories.json in Resources */,
7089CBBC1B53DD7A006C9EC5 /* get_platforms.json in Resources */,
3A13F30C1B404E7500C29D81 /* platforms.json in Resources */,
3A3853AA1B40046E00B7F842 /* create_osx_bot.json in Resources */,
3A3853A31B4002C900B7F842 /* osx_bot.json in Resources */,
3A3853A81B40046E00B7F842 /* create_ios_bot.json in Resources */,
3A3853AC1B40046E00B7F842 /* create_watch_bot.json in Resources */,
3AA922511B3F0E39005A0F73 /* scm_branches_request_with_fingerprint.json in Resources */,
3AA922541B3F0E39005A0F73 /* scm_branches_response_error.json in Resources */,
7089CBB31B53BD06006C9EC5 /* get_devices.json in Resources */,
3AA922501B3F0E39005A0F73 /* scm_branches_request_no_fingerprint.json in Resources */,
3AA922531B3F0E39005A0F73 /* scm_branches_response_success.json in Resources */,
);
Expand All @@ -767,13 +785,15 @@
buildActionMask = 2147483647;
files = (
704B5FC41B455EE400989E4B /* get_repositories.json in Resources */,
7089CBBB1B53DD7A006C9EC5 /* get_platforms.json in Resources */,
3A13F30B1B404E7500C29D81 /* platforms.json in Resources */,
3A3853A91B40046E00B7F842 /* create_osx_bot.json in Resources */,
3A3853A21B4002C900B7F842 /* osx_bot.json in Resources */,
3A3853A71B40046E00B7F842 /* create_ios_bot.json in Resources */,
3A3853AB1B40046E00B7F842 /* create_watch_bot.json in Resources */,
3AA9224C1B3F0E38005A0F73 /* scm_branches_request_with_fingerprint.json in Resources */,
3AA9224F1B3F0E38005A0F73 /* scm_branches_response_error.json in Resources */,
7089CBB21B53BD06006C9EC5 /* get_devices.json in Resources */,
3AA9224B1B3F0E38005A0F73 /* scm_branches_request_no_fingerprint.json in Resources */,
3AA9224E1B3F0E38005A0F73 /* scm_branches_response_success.json in Resources */,
);
Expand Down Expand Up @@ -867,7 +887,9 @@
3A06D5FD1B3C184400F0A6C5 /* XcodeServerEntityTests.swift in Sources */,
70C2D8391B431F1E008845FB /* RepositoryTests.swift in Sources */,
11FB71B91B34B00000D57A52 /* BotParsingTests.swift in Sources */,
703FED521B53AD1B00943876 /* DevicesTests.swift in Sources */,
11FB71BA1B34B00000D57A52 /* TestUtils.swift in Sources */,
7089CBB91B53DC9D006C9EC5 /* PlatformTests.swift in Sources */,
3A06D6001B3C184F00F0A6C5 /* BotConfigurationTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -920,7 +942,9 @@
704591861B40945700BA226C /* RepositoryTests.swift in Sources */,
3A058A931B315BB50077FD47 /* TestUtils.swift in Sources */,
3A7B48CD1B2A5AC40077ABEA /* XcodeServerTests.swift in Sources */,
703FED511B53AD1B00943876 /* DevicesTests.swift in Sources */,
709ED6801B3608FC00A06038 /* XcodeServerConfigTests.swift in Sources */,
7089CBB81B53DC9D006C9EC5 /* PlatformTests.swift in Sources */,
70B21FF81B3AFB1D00EAD4EB /* BotConfigurationTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
46 changes: 40 additions & 6 deletions XcodeServerSDK/Server Entities/Device.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,55 @@ import Foundation

public class Device : XcodeServerEntity {

public let name: String
public let simulator: Bool
public let osVersion: String
public let deviceType: String
public let connected: Bool
public let simulator: Bool
public let modelCode: String // Enum?
public let deviceType: String // Enum?
public let modelName: String
public let deviceECID: String?
public let modelUTI: String
public let activeProxiedDevice: Device?
public let docType: String
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docType is an internal Xcode Server key used in CouchDB to identify the... surprise surprise... document type. If you want to add it, it should be added to XcodeServerEntity instead, because it's also present in entities like bots and integrations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I've noticed that later and I'll move it to XcodeServerEntity.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃憤

public let trusted: Bool
public let name: String
public let supported: Bool
public let processor: String?
public let identifier: String
public let enabledForDevelopment: Bool
public let serialNumber: String?
public let platform: DevicePlatform.PlatformType
public let architecture: String // Enum?
public let isServer: Bool
public let retina: Bool

public required init(json: NSDictionary) {

self.name = json.stringForKey("name")
self.simulator = json.boolForKey("simulator")
self.osVersion = json.stringForKey("osVersion")
self.deviceType = json.stringForKey("deviceType")
self.connected = json.boolForKey("connected")
self.simulator = json.boolForKey("simulator")
self.modelCode = json.stringForKey("modelCode")
self.deviceType = json.stringForKey("deviceType")
self.modelName = json.stringForKey("modelName")
self.deviceECID = json.optionalStringForKey("deviceECID")
self.modelUTI = json.stringForKey("modelUTI")
if let proxyDevice: NSDictionary = json.optionalForKey("activeProxiedDevice") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just use if let proxyDevice = json.optionalDictionaryForKey("activeProxiedDevice") {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My mistake. Earlier I was trying to achieve this other wa around and this is a small artifact...

self.activeProxiedDevice = Device(json: proxyDevice)
} else {
self.activeProxiedDevice = nil
}
self.docType = json.stringForKey("doc_type")
self.trusted = json.boolForKey("trusted")
self.name = json.stringForKey("name")
self.supported = json.boolForKey("supported")
self.processor = json.optionalStringForKey("processor")
self.identifier = json.stringForKey("identifier")
self.enabledForDevelopment = json.boolForKey("enabledForDevelopment")
self.serialNumber = json.optionalStringForKey("serialNumber")
self.platform = DevicePlatform.PlatformType(rawValue: json.stringForKey("platformIdentifier")) ?? .Unknown
self.architecture = json.stringForKey("architecture")
self.isServer = json.boolForKey("isServer")
self.retina = json.boolForKey("retina")

super.init(json: json)
}
Expand Down