@@ -6,13 +6,32 @@ class MetadataTests: XCTestCase {
6
6
let expected : Dictionary < String , Any > = [
7
7
" canonical_url " : " http://parsely-test.com " ,
8
8
" pub_date " : Date ( ) ,
9
+ " save_date " : Date ( ) ,
9
10
" title " : " a title. " ,
10
11
" authors " : [ " Yogi Berra " ] ,
11
12
" image_url " : " http://parsely-test.com/image2 " ,
12
13
" section " : " Things my mother says " ,
13
14
" tags " : [ " tag1 " , " tag2 " ] ,
14
15
" duration " : TimeInterval ( 100 ) ,
15
- " page_type " : " post "
16
+ " page_type " : " post " ,
17
+ " urls " : " http://parsely-test.com " ,
18
+ " post_id " : " 1 " ,
19
+ " pub_date_tmsp " : Date ( ) ,
20
+ " custom_metadata " : " hedgehogs " ,
21
+ " save_date_tmsp " : Date ( ) ,
22
+ " thumb_url " : " http://parsely-test.com/image2 " ,
23
+ " full_content_word_count " : 100 ,
24
+ " share_urls " : [ " http://parsely-test.com " ] ,
25
+ " data_source " : " the moon " ,
26
+ " canonical_hash " : " hash_browns " ,
27
+ " canonical_hash64 " : " hash_browns64 " ,
28
+ " video_platform " : " youtube " ,
29
+ " language " : " en " ,
30
+ " full_content " : " the full content of the article " ,
31
+ " full_content_sha512 " : " what is this? " ,
32
+ " network_id_str " : " abc " ,
33
+ " network_canonical " : " network canonical "
34
+
16
35
]
17
36
18
37
func testToDictEmpty( ) {
@@ -33,16 +52,37 @@ class MetadataTests: XCTestCase {
33
52
let metasUnderTest = ParselyMetadata (
34
53
canonical_url: expected [ " canonical_url " ] as? String ,
35
54
pub_date: expected [ " pub_date " ] as? Date ,
55
+ save_date: expected [ " save_date " ] as? Date ,
36
56
title: expected [ " title " ] as? String ,
37
57
authors: expected [ " authors " ] as? Array < String > ,
38
58
image_url: expected [ " image_url " ] as? String ,
39
59
section: expected [ " section " ] as? String ,
40
60
tags: expected [ " tags " ] as? Array < String > ,
41
61
duration: expected [ " duration " ] as? TimeInterval ,
42
- page_type: expected [ " page_type " ] as? String
62
+ page_type: expected [ " page_type " ] as? String ,
63
+ urls: expected [ " urls " ] as? String ,
64
+ post_id: expected [ " post_id " ] as? String ,
65
+ pub_date_tmsp: expected [ " pub_date_tmsp " ] as? Date ,
66
+ custom_metadata: expected [ " custom_metadata " ] as? String ,
67
+ save_date_tmsp: expected [ " save_date_tmsp " ] as? Date ,
68
+ thumb_url: expected [ " thumb_url " ] as? String ,
69
+ full_content_word_count: expected [ " full_content_word_count " ] as? Int ,
70
+ share_urls: expected [ " share_urls " ] as? Array < String > ,
71
+ data_source: expected [ " data_source " ] as? String ,
72
+ canonical_hash: expected [ " canonical_hash " ] as? String ,
73
+ canonical_hash64: expected [ " canonical_hash64 " ] as? String ,
74
+ video_platform: expected [ " video_platform " ] as? String ,
75
+ language: expected [ " language " ] as? String ,
76
+ full_content: expected [ " full_content " ] as? String ,
77
+ full_content_sha512: expected [ " full_content_sha512 " ] as? String ,
78
+ network_id_str: expected [ " network_id_str " ] as? String ,
79
+ network_canonical: expected [ " network_canonical " ] as? String
43
80
)
44
81
let actual : Dictionary < String , Any > = metasUnderTest. toDict ( )
45
82
let pubDateUnix : String = String ( format: " %i " , ( expected [ " pub_date " ] ! as! Date ) . millisecondsSince1970)
83
+ let saveDateUnix : String = String ( format: " %i " , ( expected [ " save_date " ] ! as! Date ) . millisecondsSince1970)
84
+ let pubDateTmspUnix : String = String ( format: " %i " , ( expected [ " pub_date_tmsp " ] ! as! Date ) . millisecondsSince1970)
85
+ let saveDateTmspUnix : String = String ( format: " %i " , ( expected [ " save_date_tmsp " ] ! as! Date ) . millisecondsSince1970)
46
86
XCTAssertFalse ( actual. isEmpty, " Creating a ParselyMetadataobject with many parameters results in a " +
47
87
" non-empty object " )
48
88
XCTAssertEqual ( actual [ " link " ] ! as! String , expected [ " canonical_url " ] ! as! String ,
@@ -51,6 +91,9 @@ class MetadataTests: XCTestCase {
51
91
XCTAssertEqual ( actual [ " pub_date " ] ! as! String , pubDateUnix,
52
92
" The pub_date field in the result of ParselyMetadata.toDict should match the pub_date argument " +
53
93
" used at initialization " )
94
+ XCTAssertEqual ( actual [ " save_date " ] ! as! String , pubDateUnix,
95
+ " The save_date field in the result of ParselyMetadata.toDict should match the save_date argument " +
96
+ " used at initialization " )
54
97
XCTAssertEqual ( actual [ " title " ] ! as! String , expected [ " title " ] ! as! String ,
55
98
" The title field in the result of ParselyMetadata.toDict should match the title argument " +
56
99
" used at initialization " )
@@ -71,7 +114,58 @@ class MetadataTests: XCTestCase {
71
114
" used at initialization " )
72
115
XCTAssertEqual ( actual [ " page_type " ] ! as! String , expected [ " page_type " ] ! as! String ,
73
116
" The page_type field in the result of ParselyMetadata.toDict should match the page_type argument " +
74
- " used at initialization " )
117
+ " used at initialization " )
118
+ XCTAssertEqual ( actual [ " urls " ] ! as! String , expected [ " urls " ] ! as! String ,
119
+ " The urls field in the result of ParselyMetadata.toDict should match the urls argument " +
120
+ " used at initialization " )
121
+ XCTAssertEqual ( actual [ " post_id " ] ! as! String , expected [ " post_id " ] ! as! String ,
122
+ " The post_id field in the result of ParselyMetadata.toDict should match the post_id argument " +
123
+ " used at initialization " )
124
+ XCTAssertEqual ( actual [ " pub_date_tmsp " ] ! as! String , pubDateTmspUnix,
125
+ " The pub_date_tmsp field in the result of ParselyMetadata.toDict should match the pub_date_tmsp argument " +
126
+ " used at initialization " )
127
+ XCTAssertEqual ( actual [ " custom_metadata " ] ! as! String , expected [ " custom_metadata " ] ! as! String ,
128
+ " The custom_metadata field in the result of ParselyMetadata.toDict should match the custom_metadata argument " +
129
+ " used at initialization " )
130
+ XCTAssertEqual ( actual [ " save_date_tmsp " ] ! as! String , saveDateTmspUnix,
131
+ " The save_date_tmsp field in the result of ParselyMetadata.toDict should match the save_date_tmsp argument " +
132
+ " used at initialization " )
133
+ XCTAssertEqual ( actual [ " thumb_url " ] ! as! String , expected [ " thumb_url " ] ! as! String ,
134
+ " The thumb_url field in the result of ParselyMetadata.toDict should match the thumb_url argument " +
135
+ " used at initialization " )
136
+ XCTAssertEqual ( actual [ " full_content_word_count " ] ! as! Int , expected [ " full_content_word_count " ] ! as! Int ,
137
+ " The full_content_word_count field in the result of ParselyMetadata.toDict should match the full_content_word_count argument " +
138
+ " used at initialization " )
139
+ XCTAssertEqual ( actual [ " share_urls " ] ! as! Array < String > , expected [ " share_urls " ] ! as! Array < String > ,
140
+ " The share_urls field in the result of ParselyMetadata.toDict should match the share_urls argument " +
141
+ " used at initialization " )
142
+ XCTAssertEqual ( actual [ " data_source " ] ! as! String , expected [ " data_source " ] ! as! String ,
143
+ " The data_source field in the result of ParselyMetadata.toDict should match the data_source argument " +
144
+ " used at initialization " )
145
+ XCTAssertEqual ( actual [ " canonical_hash " ] ! as! String , expected [ " canonical_hash " ] ! as! String ,
146
+ " The canonical_hash field in the result of ParselyMetadata.toDict should match the canonical_hash argument " +
147
+ " used at initialization " )
148
+ XCTAssertEqual ( actual [ " canonical_hash64 " ] ! as! String , expected [ " canonical_hash64 " ] ! as! String ,
149
+ " The canonical_hash64 field in the result of ParselyMetadata.toDict should match the canonical_hash64 argument " +
150
+ " used at initialization " )
151
+ XCTAssertEqual ( actual [ " video_platform " ] ! as! String , expected [ " video_platform " ] ! as! String ,
152
+ " The video_platform field in the result of ParselyMetadata.toDict should match the video_platform argument " +
153
+ " used at initialization " )
154
+ XCTAssertEqual ( actual [ " language " ] ! as! String , expected [ " language " ] ! as! String ,
155
+ " The language field in the result of ParselyMetadata.toDict should match the language argument " +
156
+ " used at initialization " )
157
+ XCTAssertEqual ( actual [ " full_content " ] ! as! String , expected [ " full_content " ] ! as! String ,
158
+ " The full_content field in the result of ParselyMetadata.toDict should match the full_content argument " +
159
+ " used at initialization " )
160
+ XCTAssertEqual ( actual [ " full_content_sha512 " ] ! as! String , expected [ " full_content_sha512 " ] ! as! String ,
161
+ " The full_content_sha512 field in the result of ParselyMetadata.toDict should match the full_content_sha512 argument " +
162
+ " used at initialization " )
163
+ XCTAssertEqual ( actual [ " network_id_str " ] ! as! String , expected [ " network_id_str " ] ! as! String ,
164
+ " The network_id_str field in the result of ParselyMetadata.toDict should match the network_id_str argument " +
165
+ " used at initialization " )
166
+ XCTAssertEqual ( actual [ " network_canonical " ] ! as! String , expected [ " network_canonical " ] ! as! String ,
167
+ " The network_canonical field in the result of ParselyMetadata.toDict should match the network_canonical argument " +
168
+ " used at initialization " )
75
169
}
76
170
77
171
func testMetadata( ) {
0 commit comments