Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #495 from josh64x2/xmlchanges
XML Parsing changes
- Loading branch information
Showing
48 changed files
with
1,376 additions
and
1,598 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// BitlyAPIHelperTests.m | ||
// Vienna | ||
// | ||
// Created by Joshua Pore on 5/08/2015. | ||
// Copyright (c) 2015 uk.co.opencommunity. All rights reserved. | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
#import <XCTest/XCTest.h> | ||
#import "BitlyAPIHelper.h" | ||
|
||
@interface BitlyAPIHelperTests : XCTestCase | ||
|
||
@end | ||
|
||
@implementation BitlyAPIHelperTests | ||
|
||
- (void)setUp { | ||
[super setUp]; | ||
// Put setup code here. This method is called before the invocation of each test method in the class. | ||
} | ||
|
||
- (void)tearDown { | ||
// Put teardown code here. This method is called after the invocation of each test method in the class. | ||
[super tearDown]; | ||
} | ||
|
||
- (void)testShortenURL { | ||
// This tests the bitly shorten URL function | ||
BitlyAPIHelper * bitlyHelper = [[BitlyAPIHelper alloc] initWithLogin:@"viennarss" andAPIKey:@"R_852929122e82d2af45fe9e238f1012d3"]; | ||
NSString *shortURL = [NSString stringWithString:[bitlyHelper shortenURL:@"http://www.vienna-rss.org"]]; | ||
NSLog(@"shortened URL: %@", shortURL); | ||
XCTAssertTrue([shortURL containsString:@"bit.ly"]); | ||
} | ||
|
||
- (void)testPerformanceExample { | ||
// This is an example of a performance test case. | ||
[self measureBlock:^{ | ||
// Put the code you want to measure the time of here. | ||
}]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// | ||
// CriteriaTests.m | ||
// Vienna | ||
// | ||
// Created by Joshua Pore on 5/08/2015. | ||
// Copyright (c) 2015 uk.co.opencommunity. All rights reserved. | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
#import <XCTest/XCTest.h> | ||
#import "Criteria.h" | ||
|
||
@interface CriteriaTests : XCTestCase | ||
|
||
@end | ||
|
||
@implementation CriteriaTests | ||
|
||
- (void)setUp { | ||
[super setUp]; | ||
// Put setup code here. This method is called before the invocation of each test method in the class. | ||
} | ||
|
||
- (void)tearDown { | ||
// Put teardown code here. This method is called after the invocation of each test method in the class. | ||
[super tearDown]; | ||
} | ||
|
||
|
||
|
||
- (void)testPerformanceExample { | ||
// This is an example of a performance test case. | ||
[self measureBlock:^{ | ||
// Put the code you want to measure the time of here. | ||
}]; | ||
} | ||
@end | ||
|
||
|
||
@interface CriteriaTreeTests : XCTestCase | ||
|
||
@end | ||
|
||
@implementation CriteriaTreeTests | ||
|
||
|
||
- (void)setUp { | ||
[super setUp]; | ||
// Put setup code here. This method is called before the invocation of each test method in the class. | ||
} | ||
|
||
- (void)tearDown { | ||
// Put teardown code here. This method is called after the invocation of each test method in the class. | ||
[super tearDown]; | ||
} | ||
|
||
- (void)testCriteriaTreeInitWithString { | ||
// This tests initialising a CriteriaTree with a string. | ||
// Only called by the Database class when loading smart folders | ||
NSString *criteriaTreeString = @"<?xml version=\"1.0\" encoding=\"utf-8\"?><criteriagroup condition=\"all\"><criteria field=\"Flagged\"><operator>1</operator><value>Yes</value></criteria></criteriagroup>"; | ||
|
||
CriteriaTree *testCriteriaTree = [[CriteriaTree alloc] initWithString:criteriaTreeString]; | ||
NSArray *allCriteria = [[testCriteriaTree criteriaEnumerator] allObjects]; | ||
XCTAssertTrue([allCriteria.firstObject isKindOfClass:Criteria.class], @"Pass"); | ||
|
||
} | ||
|
||
- (void)testCriteriaTreeInitWithString2 { | ||
// This tests initialising a CriteriaTree with a string that has | ||
// multiple criteria. | ||
// Only called by the Database class when loading smart folders | ||
NSString *criteriaTreeString = @"<?xml version=\"1.0\" encoding=\"utf-8\"?><criteriagroup condition=\"all\"><criteria field=\"Flagged\"><operator>1</operator><value>Yes</value></criteria><criteria field=\"Date\"><operator>1</operator><value>today</value></criteria></criteriagroup>"; | ||
|
||
CriteriaTree *testCriteriaTree = [[CriteriaTree alloc] initWithString:criteriaTreeString]; | ||
NSArray *allCriteria = [[testCriteriaTree criteriaEnumerator] allObjects]; | ||
XCTAssertGreaterThan(allCriteria.count, 1, @"Pass"); | ||
} | ||
|
||
- (void)testCriteriaTreeString { | ||
// This tests returning a criteria tree as an XML string | ||
NSString *criteriaTreeString = @"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?><criteriagroup condition=\"all\"><criteria field=\"Flagged\"><operator>1</operator><value>Yes</value></criteria></criteriagroup>"; | ||
|
||
CriteriaTree *testCriteriaTree = [[CriteriaTree alloc] initWithString:criteriaTreeString]; | ||
XCTAssertEqualObjects([testCriteriaTree string].lowercaseString, criteriaTreeString.lowercaseString); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// | ||
// ExportTests.m | ||
// Vienna | ||
// | ||
// Created by Joshua Pore on 5/08/2015. | ||
// Copyright (c) 2015 uk.co.opencommunity. All rights reserved. | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
#import <XCTest/XCTest.h> | ||
#import "Export.h" | ||
#import "Database.h" | ||
|
||
@interface Export(Testable) | ||
+ (NSXMLDocument *)opmlDocumentFromFolders:(NSArray *)folders withGroups:(BOOL)groupFlag exportCount:(int *)countExported; | ||
@end | ||
|
||
@interface ExportTests : XCTestCase | ||
|
||
@end | ||
|
||
@implementation ExportTests | ||
|
||
- (void)setUp { | ||
[super setUp]; | ||
// Put setup code here. This method is called before the invocation of each test method in the class. | ||
} | ||
|
||
- (void)tearDown { | ||
// Put teardown code here. This method is called after the invocation of each test method in the class. | ||
[super tearDown]; | ||
} | ||
|
||
- (void)testExportWithoutGroups { | ||
// Test exporting feeds to opml file without groups | ||
NSArray *folders = [self foldersArray]; | ||
NSURL *tmpUrl = [NSURL URLWithString:@"/tmp/vienna-test-nogroups.opml"]; | ||
|
||
int countExported = [Export exportToFile:tmpUrl.absoluteString from:folders withGroups:NO]; | ||
XCTAssertGreaterThan(countExported, 0, @"Pass"); | ||
} | ||
|
||
- (void)testExportWithGroups { | ||
// Test exporting feeds to opml file without groups | ||
NSArray *folders = [self foldersArray]; | ||
NSURL *tmpUrl = [NSURL URLWithString:@"/tmp/vienna-test-groups.opml"]; | ||
|
||
int countExported = [Export exportToFile:tmpUrl.absoluteString from:folders withGroups:YES]; | ||
XCTAssertGreaterThan(countExported, 0, @"Pass"); | ||
} | ||
|
||
|
||
// Test helper method to return an array of folders for export | ||
- (NSArray *)foldersArray { | ||
Database *db = [Database sharedManager]; | ||
NSArray *foldersArray = [db arrayOfFolders:MA_Root_Folder]; | ||
return foldersArray; | ||
} | ||
|
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// | ||
// RichXMLParserTests.m | ||
// Vienna | ||
// | ||
// Created by Joshua Pore on 7/08/2015. | ||
// Copyright (c) 2015 uk.co.opencommunity. All rights reserved. | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
#import <XCTest/XCTest.h> | ||
#import "RichXMLParser.h" | ||
|
||
@interface RichXMLParserTests : XCTestCase | ||
|
||
@end | ||
|
||
@implementation RichXMLParserTests | ||
|
||
- (void)setUp { | ||
[super setUp]; | ||
// Put setup code here. This method is called before the invocation of each test method in the class. | ||
} | ||
|
||
- (void)tearDown { | ||
// Put teardown code here. This method is called after the invocation of each test method in the class. | ||
[super tearDown]; | ||
} | ||
|
||
- (void)testParseRichXML { | ||
BOOL success = NO; | ||
// Test extracting feeds to an array | ||
NSURL *url = [NSURL fileURLWithPath:@"/Users/josh/test.rdf"]; | ||
// old parser | ||
NSData *feedData = [NSData dataWithContentsOfURL:url]; | ||
RichXMLParser *oldParser = [[RichXMLParser alloc] init]; | ||
BOOL oldParsedOK = [oldParser parseRichXML:feedData]; | ||
// new parser | ||
if (oldParsedOK){ | ||
|
||
} | ||
XCTAssertTrue(success, "Pass"); | ||
} | ||
|
||
//- (void)testPerformanceExample { | ||
// // This is an example of a performance test case. | ||
// [self measureBlock:^{ | ||
// // Put the code you want to measure the time of here. | ||
// }]; | ||
//} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.