Skip to content

Commit

Permalink
hold: testExtractAssetImports for later time
Browse files Browse the repository at this point in the history
  • Loading branch information
devahmedshendy committed Aug 30, 2023
1 parent 2594479 commit d7ca550
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Sources/ContributeWordPress/Images/AssetImport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public struct AssetImport: Hashable {
featuredPath: String,
parentID: Int
) {
fromURL = importFromURL
atURL = importAtURL
self.fromURL = importFromURL
self.atURL = importAtURL
self.featuredPath = featuredPath
self.parentID = parentID
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ extension WordPressPost {
description: "My main goal this year was to produce more content online and less time on local events and gatherings. Unfortunately, that wasn't the case.",
postName: "2018-review",
contentEncoded: .myYearInReviewContent,
categories: tags ?? []
categories: tags ?? [],
postID: 1
)
}

Expand All @@ -23,7 +24,8 @@ extension WordPressPost {
link: URL(string: "https://leogdion.name/2018/12/13/are-we-there-yet/")!,
postName: "are-we-there-yet",
contentEncoded: .areWeThereYetContent,
categories: tags ?? []
categories: tags ?? [],
postID: 2
)
}

Expand All @@ -33,7 +35,8 @@ extension WordPressPost {
link: URL(string: "https://leogdion.name/2018/01/08/from-goals-to-actions-2018/diagram-for-goals/")!,
postName: "from-goals-to-actions-2018",
contentEncoded: .fromGoalsToActionsContent,
categories: tags ?? []
categories: tags ?? [],
postID: 3
)
}

Expand All @@ -44,7 +47,8 @@ extension WordPressPost {
description: "Generally speaking, podcasting gives specific audiences an in-depth specialized analysis without the need to appeal to the general audience.",
postName: "podcasting-getting-started-content-recording-audience",
contentEncoded: .podcastingContent,
categories: tags ?? []
categories: tags ?? [],
postID: 4
)
}

Expand All @@ -57,22 +61,38 @@ extension WordPressPost {
description: "It's important to keep a set of great productivity app which help me optimize rather than distract. Here's a list of productivity apps and services to help you.",
postName: "productivity-apps-for-developers-and-everyone",
contentEncoded: .productivityContent,
categories: tags ?? []
categories: tags ?? [],
postID: 4
)
}
}

extension WordPressPost {
internal static func attachmentA() throws -> WordPressPost {
try .make(title: "\(#function)", type: "attachment", contentEncoded: "")
internal static func attachmentA(postID: Int = 1) throws -> WordPressPost {
try .make(
title: "\(#function)",
type: "attachment",
contentEncoded: "",
postID: postID
)
}

internal static func attachmentB() throws -> WordPressPost {
try .make(title: "\(#function)", type: "attachment", contentEncoded: "")
internal static func attachmentB(postID: Int = 1) throws -> WordPressPost {
try .make(
title: "\(#function)",
type: "attachment",
contentEncoded: "",
postID: postID
)
}

internal static func attachmentC() throws -> WordPressPost {
try .make(title: "\(#function)", type: "attachment", contentEncoded: "")
internal static func attachmentC(postID: Int = 1) throws -> WordPressPost {
try .make(
title: "\(#function)",
type: "attachment",
contentEncoded: "",
postID: postID
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ extension RSSItem {
postDate: Date?,
categories: [RSSItemCategory],
creators: [String],
postID: Int,
status: String,
attachmentURL: URL?
) -> RSSItem {
Expand Down Expand Up @@ -46,7 +47,7 @@ extension RSSItem {
wpMenuOrder: .bitWidth,
wpIsSticky: .bitWidth,
wpPostPassword: .init(),
wpPostID: 10,
wpPostID: postID,
wpPostDate: postDate,
wpPostDateGMT: .distantFuture,
wpModifiedDate: .distantFuture,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ extension WordPressPost {
contentEncoded: String? = nil,
categories: [RSSItemCategory] = [.Podcasting, .Productivity],
creators: [String] = ["Leo"],
postID: Int,
status: String = "publish",
attachmentURL: URL? = nil
) throws -> WordPressPost {
Expand All @@ -30,6 +31,7 @@ extension WordPressPost {
postDate: postDate,
categories: categories,
creators: creators,
postID: postID,
status: status,
attachmentURL: attachmentURL
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,29 @@ internal final class AssetImportWordPressTests: XCTestCase {
let site: WordPressSite = try .make(
link: try .make(string: "https://leogdion.name"),
posts: [
.productivityAppsPost()
.myYearInReviewPost()
]
)

let rootPublishSiteURL: URL = .temporaryDirURL
let expoertingDirectoryURL: URL = rootPublishSiteURL
.appendingPathComponent("WordPress/exports")

let assetImports = AssetImport.extractAssetImports(
from: site,
using: Settings(
rootPublishSiteURL: rootPublishSiteURL,
exportsDirectoryURL: rootPublishSiteURL
.appendingPathComponent("WordPress/exports")
exportsDirectoryURL: expoertingDirectoryURL
)
)

// TODO: Write the actual tests
// TODO: Only this final tests needs to be finished
for assetImport in assetImports {
print(assetImport.fromURL)
print(assetImport.atURL)
// XCTAssertEqual(assetImport.parentID, site.???)

print("fromURL: " + assetImport.fromURL.absoluteString)
print("fromURL: " + assetImport.fromURL.absoluteString)
print("parentID: \(assetImport.parentID)")
}
}
}

0 comments on commit d7ca550

Please sign in to comment.