Skip to content

Commit

Permalink
Merge pull request #496 from Piwigo/v2.9.4
Browse files Browse the repository at this point in the history
v2.9.4
  • Loading branch information
EddyLB authored Feb 23, 2022
2 parents 62e95b6 + 80fa0f4 commit 24140f1
Show file tree
Hide file tree
Showing 115 changed files with 2,412 additions and 1,891 deletions.
2 changes: 1 addition & 1 deletion Supporting Targets/piwigoKit/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>441</string>
<string>443</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"result": {
"real_user_status" : "webmaster",
"upload_categories_getList_method" : "pwg.categories.getAdminList"
},
"stat": "ok"
}
152 changes: 143 additions & 9 deletions Supporting Targets/piwigoWebAPI/piwigoWebAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,49 @@ import XCTest
import piwigoKit

class piwigoWebAPI: XCTestCase {

// MARK: - community.…
func testCommunityImagesUploadCompletedDecoding() {

// Case of a successful request
let bundle = Bundle(for: type(of: self))
guard let url = bundle.url(forResource: "community.images.uploadCompleted", withExtension: "json"),
let data = try? Data(contentsOf: url) else {
XCTFail("Could not load resource file")
return
}

let decoder = JSONDecoder()
guard let result = try? decoder.decode(CommunityImagesUploadCompletedJSON.self, from: data) else {
XCTFail()
return
}

XCTAssertEqual(result.status, "ok")
XCTAssertTrue(result.data.contains(where: { $0.id == "51768" }))
}

func testCommunitySessionGetStatusDecoding() {

// Case of a successful request
let bundle = Bundle(for: type(of: self))
guard let url = bundle.url(forResource: "community.session.getStatus", withExtension: "json"),
let data = try? Data(contentsOf: url) else {
XCTFail("Could not load resource file")
return
}

let decoder = JSONDecoder()
guard let result = try? decoder.decode(CommunitySessionGetStatusJSON.self, from: data) else {
XCTFail()
return
}

XCTAssertEqual(result.status, "ok")
XCTAssertEqual(result.realUser, "webmaster")
XCTAssertEqual(result.uploadMethod, "pwg.categories.getAdminList")
}


// MARK: - pwg.…
func testPwgGetInfosDecoding() {
Expand Down Expand Up @@ -173,6 +216,87 @@ class piwigoWebAPI: XCTestCase {
}


// MARK: - pwg.session.…
func testPwgSessionLoginDecoding() {
// Case of a successful request
let bundle = Bundle(for: type(of: self))
guard let url = bundle.url(forResource: "pwg.session.login", withExtension: "json"),
var data = try? Data(contentsOf: url) else {
XCTFail("Could not load resource file")
return
}

// Clean returned data
if !data.isPiwigoResponseValid(for: SessionLoginJSON.self) {
XCTFail()
return
}

// Is this a valid JSON object?
let decoder = JSONDecoder()
guard let result = try? decoder.decode(SessionLoginJSON.self, from: data) else {
XCTFail()
return
}

XCTAssertEqual(result.status, "ok")
XCTAssertEqual(result.errorCode, 0)
XCTAssertEqual(result.errorMessage, "")

XCTAssertEqual(result.success, true)
}

func testPwgSessionGetStatusDecoding() {

// Case of a successful request
let bundle = Bundle(for: type(of: self))
guard let url = bundle.url(forResource: "pwg.session.getStatus", withExtension: "json"),
let data = try? Data(contentsOf: url) else {
XCTFail("Could not load resource file")
return
}

let decoder = JSONDecoder()
guard let result = try? decoder.decode(SessionGetStatusJSON.self, from: data) else {
XCTFail()
return
}

XCTAssertEqual(result.status, "ok")
XCTAssertEqual(result.data?.userName, "Eddy")
XCTAssertEqual(result.data?.language, "fr_FR")
}

func testPwgSessionLogoutDecoding() {
// Case of a successful request
let bundle = Bundle(for: type(of: self))
guard let url = bundle.url(forResource: "pwg.session.logout", withExtension: "json"),
var data = try? Data(contentsOf: url) else {
XCTFail("Could not load resource file")
return
}

// Clean returned data
if !data.isPiwigoResponseValid(for: SessionLogoutJSON.self) {
XCTFail()
return
}

// Is this a valid JSON object?
let decoder = JSONDecoder()
guard let result = try? decoder.decode(SessionLogoutJSON.self, from: data) else {
XCTFail()
return
}

XCTAssertEqual(result.status, "ok")
XCTAssertEqual(result.errorCode, 0)
XCTAssertEqual(result.errorMessage, "")

XCTAssertEqual(result.success, true)
}


// MARK: - pwg.tags…
func testPwgTagsGetListDecoding() {

Expand Down Expand Up @@ -258,25 +382,35 @@ class piwigoWebAPI: XCTestCase {
XCTAssertEqual(result.result, true)
}


// MARK: - community
func testCommunityImagesUploadCompletedDecoding() {


// MARK: - reflection.…
func testReflectionGetMethodListDecoding() {
// Case of a successful request
let bundle = Bundle(for: type(of: self))
guard let url = bundle.url(forResource: "community.images.uploadCompleted", withExtension: "json"),
let data = try? Data(contentsOf: url) else {
guard let url = bundle.url(forResource: "reflection.getMethodList", withExtension: "json"),
var data = try? Data(contentsOf: url) else {
XCTFail("Could not load resource file")
return
}

// Clean returned data
if !data.isPiwigoResponseValid(for: ReflectionGetMethodListJSON.self) {
XCTFail()
return
}

// Is this a valid JSON object?
let decoder = JSONDecoder()
guard let result = try? decoder.decode(CommunityImagesUploadCompletedJSON.self, from: data) else {
guard let result = try? decoder.decode(ReflectionGetMethodListJSON.self, from: data) else {
XCTFail()
return
}

XCTAssertEqual(result.status, "ok")
XCTAssertTrue(result.data.contains(where: { $0.id == "51768" }))
XCTAssertEqual(result.errorCode, 0)
XCTAssertEqual(result.errorMessage, "")

XCTAssertEqual(result.data[0], "community.categories.getList")
XCTAssertEqual(result.data[1], "community.images.uploadCompleted")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"result": {
"available_sizes": [
"square",
"thumb",
"2small",
"xsmall",
"small",
"medium",
"large",
"xlarge",
"xxlarge"
],
"charset": "utf-8",
"current_datetime": "2022-02-19 23:04:17",
"language": "fr_FR",
"pwg_token": "8814066d722b4ce75aaa5110e0019b9f",
"status": "webmaster",
"theme": "bootstrap_darkroom",
"upload_file_types": "jpg,jpeg,png,gif,tif,tiff,mp4,m4v,mpg,ogg,ogv,webm,webmv,strm",
"upload_form_chunk_size": 1024,
"username": "Eddy",
"version": "12.2.0"
},
"stat": "ok"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"stat": "ok",
"result": 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"stat": "ok",
"result": 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"stat": "ok",
"result": {
"methods": [
"community.categories.getList",
"community.images.uploadCompleted",
"community.session.getStatus",
"pwg.activity.downloadLog",
"pwg.activity.getList",
"pwg.caddie.add",
"pwg.categories.add",
"pwg.categories.calculateOrphans",
"pwg.categories.delete",
"pwg.categories.deleteRepresentative",
"pwg.categories.getAdminList",
"pwg.categories.getImages",
"pwg.categories.getList",
"pwg.categories.move",
"pwg.categories.refreshRepresentative",
"pwg.categories.setInfo",
"pwg.categories.setRank",
"pwg.categories.setRepresentative",
"pwg.extensions.checkUpdates",
"pwg.extensions.ignoreUpdate",
"pwg.extensions.update",
"pwg.getCacheSize",
"pwg.getInfos",
"pwg.getMissingDerivatives",
"pwg.getVersion",
"pwg.groups.add",
"pwg.groups.addUser",
"pwg.groups.delete",
"pwg.groups.deleteUser",
"pwg.groups.duplicate",
"pwg.groups.getList",
"pwg.groups.merge",
"pwg.groups.setInfo",
"pwg.image.rotate",
"pwg.images.add",
"pwg.images.addChunk",
"pwg.images.addComment",
"pwg.images.addFile",
"pwg.images.addSimple",
"pwg.images.checkFiles",
"pwg.images.checkUpload",
"pwg.images.delete",
"pwg.images.deleteOrphans",
"pwg.images.emptyLounge",
"pwg.images.exist",
"pwg.images.getInfo",
"pwg.images.rate",
"pwg.images.search",
"pwg.images.setInfo",
"pwg.images.setMd5sum",
"pwg.images.setPrivacyLevel",
"pwg.images.setRank",
"pwg.images.syncMetadata",
"pwg.images.upload",
"pwg.images.uploadAsync",
"pwg.images.uploadCompleted",
"pwg.permissions.add",
"pwg.permissions.getList",
"pwg.permissions.remove",
"pwg.plugins.getList",
"pwg.plugins.performAction",
"pwg.rates.delete",
"pwg.session.getStatus",
"pwg.session.login",
"pwg.session.logout",
"pwg.tags.add",
"pwg.tags.delete",
"pwg.tags.duplicate",
"pwg.tags.getAdminList",
"pwg.tags.getImages",
"pwg.tags.getList",
"pwg.tags.merge",
"pwg.tags.rename",
"pwg.themes.performAction",
"pwg.users.add",
"pwg.users.delete",
"pwg.users.favorites.add",
"pwg.users.favorites.getList",
"pwg.users.favorites.remove",
"pwg.users.getAuthKey",
"pwg.users.getList",
"pwg.users.setInfo",
"reflection.getMethodDetails",
"reflection.getMethodList"
]
}
}
Loading

0 comments on commit 24140f1

Please sign in to comment.