Skip to content
This repository has been archived by the owner on Jun 30, 2023. It is now read-only.

Commit

Permalink
Merge pull request #111 from mironal/test-collection-v1
Browse files Browse the repository at this point in the history
Test collection v1
  • Loading branch information
mironal committed Mar 16, 2022
2 parents 1a36bfa + 3a9a721 commit 69f4043
Show file tree
Hide file tree
Showing 10 changed files with 400 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import TwitterAPIKit
import XCTest

class GetCollectionsEntriesRequestV1Tests: XCTestCase {
override func setUpWithError() throws {
}

override func tearDownWithError() throws {
}

func test() throws {
let req = GetCollectionsEntriesRequestV1(
id: "_i_",
count: 12,
maxPosition: "_m_",
minPosition: "_m_"
)

XCTAssertEqual(req.method, .get)
XCTAssertEqual(req.baseURLType, .api)
XCTAssertEqual(req.path, "/1.1/collections/entries.json")
XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded)
AssertEqualAnyDict(
req.parameters,
[
"id": "_i_",
"count": 12,
"max_position": "_m_",
"min_position": "_m_",
]
)
}

func testDefaultArg() throws {
let req = GetCollectionsEntriesRequestV1(
id: "i"
)

AssertEqualAnyDict(
req.parameters,
[
"id": "i"
]
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import TwitterAPIKit
import XCTest

class GetCollectionsListRequestV1Tests: XCTestCase {
override func setUpWithError() throws {
}

override func tearDownWithError() throws {
}

func test() throws {
let req = GetCollectionsListRequestV1(
user: .userID("uid"),
count: 14,
cursor: "_c_",
tweetID: "_t_"
)

XCTAssertEqual(req.method, .get)
XCTAssertEqual(req.baseURLType, .api)
XCTAssertEqual(req.path, "/1.1/collections/list.json")
XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded)
AssertEqualAnyDict(
req.parameters,
[
"user_id": "uid",
"count": 14,
"cursor": "_c_",
"tweet_id": "_t_",
]
)
}

func testDefaultArg() throws {
let req = GetCollectionsListRequestV1(
user: .screenName("s")
)

AssertEqualAnyDict(
req.parameters,
[
"screen_name": "s"
]
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import TwitterAPIKit
import XCTest

class GetCollectionsShowRequestV1Tests: XCTestCase {
override func setUpWithError() throws {
}

override func tearDownWithError() throws {
}

func test() throws {
let req = GetCollectionsShowRequestV1(
id: "_i_"
)

XCTAssertEqual(req.method, .get)
XCTAssertEqual(req.baseURLType, .api)
XCTAssertEqual(req.path, "/1.1/collections/show.json")
XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded)
AssertEqualAnyDict(
req.parameters,
[
"id": "_i_"
]
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import TwitterAPIKit
import XCTest

class PostCollectionsCreateRequestV1Tests: XCTestCase {
override func setUpWithError() throws {
}

override func tearDownWithError() throws {
}

func test() throws {
let req = PostCollectionsCreateRequestV1(
name: "_n_",
url: "_u_",
description: "_d_",
timelineOrder: .curationReverseChron
)

XCTAssertEqual(req.method, .post)
XCTAssertEqual(req.baseURLType, .api)
XCTAssertEqual(req.path, "/1.1/collections/create.json")
XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded)
AssertEqualAnyDict(
req.parameters,
[
"name": "_n_",
"url": "_u_",
"description": "_d_",
"timeline_order": "curation_reverse_chron",
]
)
}

func testDefaultArg() throws {
let req = PostCollectionsCreateRequestV1(
name: "n"
)

AssertEqualAnyDict(
req.parameters,
[
"name": "n"
]
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import TwitterAPIKit
import XCTest

class PostCollectionsDestroyRequestV1Tests: XCTestCase {
override func setUpWithError() throws {
}

override func tearDownWithError() throws {
}

func test() throws {
let req = PostCollectionsDestroyRequestV1(
id: "_i_"
)

XCTAssertEqual(req.method, .post)
XCTAssertEqual(req.baseURLType, .api)
XCTAssertEqual(req.path, "/1.1/collections/destroy.json")
XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded)
AssertEqualAnyDict(
req.parameters,
[
"id": "_i_"
]
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import TwitterAPIKit
import XCTest

class PostCollectionsEntriesAddRequestV1Tests: XCTestCase {
override func setUpWithError() throws {
}

override func tearDownWithError() throws {
}

func test() throws {
let req = PostCollectionsEntriesAddRequestV1(
id: "_i_",
tweetID: "_t_",
above: true,
relativeTo: "_r_"
)

XCTAssertEqual(req.method, .post)
XCTAssertEqual(req.baseURLType, .api)
XCTAssertEqual(req.path, "/1.1/collections/entries/add.json")
XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded)
AssertEqualAnyDict(
req.parameters,
[
"id": "_i_",
"tweet_id": "_t_",
"above": true,
"relative_to": "_r_",
]
)
}

func testDefaultArg() throws {
let req = PostCollectionsEntriesAddRequestV1(
id: "_i_",
tweetID: "_t_"
)

AssertEqualAnyDict(
req.parameters,
[
"id": "_i_",
"tweet_id": "_t_",
]
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import TwitterAPIKit
import XCTest

class PostCollectionsEntriesCurateRequestV1Tests: XCTestCase {
override func setUpWithError() throws {
}

override func tearDownWithError() throws {
}

func test() throws {
let req = PostCollectionsEntriesCurateRequestV1(
id: "_i_",
changes: [
.add(tweetID: "add_id"),
.remove(tweetID: "remove_id"),
]
)

XCTAssertEqual(req.method, .post)
XCTAssertEqual(req.baseURLType, .api)
XCTAssertEqual(req.path, "/1.1/collections/entries/curate.json")
XCTAssertEqual(req.bodyContentType, .json)
AssertEqualAnyDict(
req.parameters,
[
"id": "_i_",
"changes": [
["op": "add", "tweet_id": "add_id"],
["op": "remove", "tweet_id": "remove_id"],
],
]
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import TwitterAPIKit
import XCTest

class PostCollectionsEntriesMoveRequestV1Tests: XCTestCase {
override func setUpWithError() throws {
}

override func tearDownWithError() throws {
}

func test() throws {
let req = PostCollectionsEntriesMoveRequestV1(
id: "_i_",
tweetID: "_t_",
above: true,
relativeTo: "_r_"
)

XCTAssertEqual(req.method, .post)
XCTAssertEqual(req.baseURLType, .api)
XCTAssertEqual(req.path, "/1.1/collections/entries/move.json")
XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded)
AssertEqualAnyDict(
req.parameters,
[
"id": "_i_",
"tweet_id": "_t_",
"above": true,
"relative_to": "_r_",
]
)
}

func testDefaultArg() throws {
let req = PostCollectionsEntriesMoveRequestV1(
id: "_i_",
tweetID: "_t_",
relativeTo: "_r_"
)

AssertEqualAnyDict(
req.parameters,
[
"id": "_i_",
"tweet_id": "_t_",
"relative_to": "_r_",
]
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import TwitterAPIKit
import XCTest

class PostCollectionsEntriesRemoveRequestV1Tests: XCTestCase {
override func setUpWithError() throws {
}

override func tearDownWithError() throws {
}

func test() throws {
let req = PostCollectionsEntriesRemoveRequestV1(
id: "_i_",
tweetID: "_t_"
)

XCTAssertEqual(req.method, .post)
XCTAssertEqual(req.baseURLType, .api)
XCTAssertEqual(req.path, "/1.1/collections/entries/remove.json")
XCTAssertEqual(req.bodyContentType, .wwwFormUrlEncoded)
AssertEqualAnyDict(
req.parameters,
[
"id": "_i_",
"tweet_id": "_t_",
]
)
}
}

0 comments on commit 69f4043

Please sign in to comment.