-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathunit_LabelApiTests.swift
80 lines (73 loc) · 2.63 KB
/
unit_LabelApiTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//
// unit_LabelApiTests.swift
// YM-API
//
// Created by Developer on 15.10.2021.
//
import XCTest
#if canImport(YmuzApiMac)
@testable import YmuzApiMac
#endif
#if canImport(YmuzApi)
@testable import YmuzApi
#endif
class unit_LabelApiTests: XCTestCase {
var client: YMClient!
var device: YMDevice {get {return TestConstants.device}}
var apiLang: ApiLanguage {get {return TestConstants.apiLang}}
var token: String {get {return TestCredentials.token}}
var xToken: String {get {return TestCredentials.xToken}}
var uid: Int {get {return TestCredentials.uid}}
override func setUp() {
client = YMClient.initialize(device: device, lang: apiLang, uid: uid, token: token, xToken: xToken)
}
override func tearDown() {
client = nil
}
func testLabelAlbumsResponse() {
let exp = self.expectation(description: "Request time-out expectation")
//Label studio Kitsune France, ID - 449298
let labelId = "449298"
client.getLabelAlbums(labelId: labelId, page: 0) { result in
do {
let labelInfo = try result.get()
XCTAssertTrue(labelInfo.albums != nil, "Label albums is nil")
XCTAssertFalse(labelInfo.albums?.count == 0, "Label albums is empty")
} catch {
print(error)
XCTAssert(false, "Empty Label albums info object: " + error.localizedDescription)
}
exp.fulfill()
}
waitForExpectations(timeout: 5) { error in
if let g_error = error
{
print(g_error)
XCTAssert(false, "Timeout error: " + g_error.localizedDescription)
}
}
}
func testLabelArtistsResponse() {
let exp = self.expectation(description: "Request time-out expectation")
//Label studio Kitsune France, ID - 449298
let labelId = "449298"
client.getLabelArtists(labelId: labelId, page: 0) { result in
do {
let labelInfo = try result.get()
XCTAssertTrue(labelInfo.artists != nil, "Label artists is nil")
XCTAssertFalse(labelInfo.artists?.count == 0, "Label artists is empty")
} catch {
print(error)
XCTAssert(false, "Empty Label artists info object: " + error.localizedDescription)
}
exp.fulfill()
}
waitForExpectations(timeout: 5) { error in
if let g_error = error
{
print(g_error)
XCTAssert(false, "Timeout error: " + g_error.localizedDescription)
}
}
}
}