forked from loafle/openapi-generator-original
Remove outdated tests in objc client
This commit is contained in:
parent
dfa17d2291
commit
989641892e
@ -1,9 +0,0 @@
|
||||
#import <SenTestingKit/SenTestingKit.h>
|
||||
#import "RVBPetApi.h"
|
||||
|
||||
@interface PetApiTest : SenTestCase {
|
||||
@private
|
||||
RVBPetApi * api;
|
||||
}
|
||||
|
||||
@end
|
@ -1,324 +0,0 @@
|
||||
#import "PetApiTest.h"
|
||||
#import "NIKFile.h"
|
||||
|
||||
@implementation PetApiTest
|
||||
|
||||
- (void)setUp {
|
||||
[super setUp];
|
||||
api = [[RVBPetApi alloc ]init];
|
||||
}
|
||||
|
||||
- (void)tearDown {
|
||||
[super tearDown];
|
||||
}
|
||||
|
||||
- (void)testGetPetById {
|
||||
bool done = false;
|
||||
static RVBPet* pet = nil;
|
||||
static NSError * gError = nil;
|
||||
|
||||
[api getPetByIdWithCompletionBlock:@"1" completionHandler:^(RVBPet *output, NSError *error) {
|
||||
if(error) {
|
||||
gError = error;
|
||||
}
|
||||
if(output == nil){
|
||||
NSLog(@"failed to fetch pet");
|
||||
}
|
||||
else {
|
||||
pet = [[RVBPet alloc] initWithValues:[output asDictionary]];
|
||||
}
|
||||
}];
|
||||
|
||||
NSDate * loopUntil = [NSDate dateWithTimeIntervalSinceNow:10];
|
||||
while(!done && [loopUntil timeIntervalSinceNow] > 0){
|
||||
if(gError){
|
||||
STFail(@"got error %@", gError);
|
||||
done = true;
|
||||
}
|
||||
if(pet){
|
||||
STAssertNotNil([pet _id], @"token was nil");
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
STAssertNotNil(pet, @"failed to fetch valid result in 10 seconds");
|
||||
}
|
||||
|
||||
- (void) testAddPet {
|
||||
bool done = false;
|
||||
static NSError * gError = nil;
|
||||
|
||||
RVBPet * petToAdd = [[RVBPet alloc] init];
|
||||
[petToAdd set_id:@"1000"];
|
||||
NSMutableArray* tags = [[NSMutableArray alloc] init];
|
||||
for(int i = 0; i < 5; i++){
|
||||
RVBTag * tag = [[RVBTag alloc] init];
|
||||
[tag set_id:[NSNumber numberWithInt:i]];
|
||||
[tag setName:[NSString stringWithFormat:@"tag-%d", i]];
|
||||
[tags addObject:tag];
|
||||
}
|
||||
[petToAdd setTags:tags];
|
||||
[petToAdd setStatus:@"lost"];
|
||||
|
||||
RVBCategory * category = [[RVBCategory alloc] init];
|
||||
[category setName:@"sold"];
|
||||
[petToAdd setCategory:category];
|
||||
[petToAdd setName:@"dragon"];
|
||||
|
||||
NSMutableArray* photos = [[NSMutableArray alloc] init];
|
||||
for(int i = 0; i < 10; i++){
|
||||
NSString * url = [NSString stringWithFormat:@"http://foo.com/photo/%d", i];
|
||||
[photos addObject:url];
|
||||
}
|
||||
[petToAdd setPhotoUrls:photos];
|
||||
|
||||
static bool hasResponse = false;
|
||||
[api addPetWithCompletionBlock:petToAdd completionHandler:^(NSError *error) {
|
||||
if(error) {
|
||||
gError = error;
|
||||
}
|
||||
hasResponse = true;
|
||||
}];
|
||||
NSDate * loopUntil = [NSDate dateWithTimeIntervalSinceNow:10];
|
||||
while(!done && [loopUntil timeIntervalSinceNow] > 0){
|
||||
if(gError){
|
||||
STFail(@"got error %@", gError);
|
||||
done = true;
|
||||
}
|
||||
if(hasResponse){
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
|
||||
static RVBPet* pet = nil;
|
||||
|
||||
[api getPetByIdWithCompletionBlock:[NSString stringWithFormat:@"%@",[petToAdd _id]] completionHandler:^(RVBPet *output, NSError *error) {
|
||||
if(error) {
|
||||
gError = error;
|
||||
}
|
||||
if(output == nil){
|
||||
NSLog(@"failed to fetch pet");
|
||||
}
|
||||
else {
|
||||
pet = [[RVBPet alloc] initWithValues:[output asDictionary]];
|
||||
}
|
||||
}];
|
||||
|
||||
loopUntil = [NSDate dateWithTimeIntervalSinceNow:10];
|
||||
done = false;
|
||||
while(!done && [loopUntil timeIntervalSinceNow] > 0){
|
||||
if(gError){
|
||||
STFail(@"got error %@", gError);
|
||||
done = true;
|
||||
}
|
||||
if(pet){
|
||||
STAssertNotNil([pet _id], @"pet was nil");
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
STAssertNotNil(pet, @"failed to fetch valid result in 10 seconds");
|
||||
|
||||
}
|
||||
|
||||
- (void) testUpdatePet {
|
||||
bool done = false;
|
||||
static NSError * gError = nil;
|
||||
|
||||
RVBPet * petToAdd = [[RVBPet alloc] init];
|
||||
[petToAdd set_id:[NSNumber numberWithInt:1000]];
|
||||
NSMutableArray* tags = [[NSMutableArray alloc] init];
|
||||
for(int i = 0; i < 5; i++){
|
||||
RVBTag * tag = [[RVBTag alloc] init];
|
||||
[tag set_id:[NSNumber numberWithInt:i]];
|
||||
[tag setName:[NSString stringWithFormat:@"tag-%d", i]];
|
||||
[tags addObject:tag];
|
||||
}
|
||||
[petToAdd setTags:tags];
|
||||
[petToAdd setStatus:@"lost"];
|
||||
|
||||
RVBCategory * category = [[RVBCategory alloc] init];
|
||||
[category setName:@"sold"];
|
||||
[petToAdd setCategory:category];
|
||||
[petToAdd setName:@"dragon"];
|
||||
|
||||
NSMutableArray* photos = [[NSMutableArray alloc] init];
|
||||
for(int i = 0; i < 10; i++){
|
||||
NSString * url = [NSString stringWithFormat:@"http://foo.com/photo/%d", i];
|
||||
[photos addObject:url];
|
||||
}
|
||||
[petToAdd setPhotoUrls:photos];
|
||||
|
||||
static bool hasResponse = false;
|
||||
[api addPetWithCompletionBlock:petToAdd completionHandler:^(NSError *error) {
|
||||
if(error) {
|
||||
gError = error;
|
||||
}
|
||||
hasResponse = true;
|
||||
}];
|
||||
NSDate * loopUntil = [NSDate dateWithTimeIntervalSinceNow:10];
|
||||
done = false;
|
||||
while(!done && [loopUntil timeIntervalSinceNow] > 0){
|
||||
if(gError){
|
||||
done = true;
|
||||
STFail(@"got error %@", gError);
|
||||
}
|
||||
if(hasResponse){
|
||||
done = true;
|
||||
NSLog(@"pet was added");
|
||||
}
|
||||
}
|
||||
|
||||
static RVBPet* pet = nil;
|
||||
done = false;
|
||||
|
||||
[api getPetByIdWithCompletionBlock:[NSString stringWithFormat:@"%@",[petToAdd _id]] completionHandler:^(RVBPet *output, NSError *error) {
|
||||
if(error) {
|
||||
gError = error;
|
||||
}
|
||||
if(output == nil){
|
||||
NSLog(@"failed to fetch pet");
|
||||
}
|
||||
else {
|
||||
pet = [[RVBPet alloc] initWithValues:[output asDictionary]];
|
||||
NSLog(@"got the pet");
|
||||
}
|
||||
}];
|
||||
|
||||
loopUntil = [NSDate dateWithTimeIntervalSinceNow:10];
|
||||
while(!done && [loopUntil timeIntervalSinceNow] > 0){
|
||||
if(gError){
|
||||
STFail(@"got error %@", gError);
|
||||
done = true;
|
||||
}
|
||||
if(pet){
|
||||
STAssertNotNil([pet _id], @"pet was nil");
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
STAssertNotNil(pet, @"failed to fetch valid result in 10 seconds");
|
||||
|
||||
[pet setName:@"programmer"];
|
||||
[pet setStatus:@"confused"];
|
||||
|
||||
hasResponse = false;
|
||||
[api updatePetWithCompletionBlock:pet
|
||||
completionHandler:^(NSError *error) {
|
||||
if(error) {
|
||||
gError = error;
|
||||
}
|
||||
hasResponse = true;
|
||||
}];
|
||||
|
||||
loopUntil = [NSDate dateWithTimeIntervalSinceNow:10];
|
||||
done = false;
|
||||
while(!done && [loopUntil timeIntervalSinceNow] > 0){
|
||||
if(gError){
|
||||
STFail(@"got error %@", gError);
|
||||
done = true;
|
||||
}
|
||||
else if(hasResponse) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
|
||||
pet = nil;
|
||||
done = false;
|
||||
|
||||
[api getPetByIdWithCompletionBlock:[NSString stringWithFormat:@"%d",1000] completionHandler:^(RVBPet *output, NSError *error) {
|
||||
if(error) {
|
||||
gError = error;
|
||||
}
|
||||
if(output == nil){
|
||||
NSLog(@"failed to fetch pet");
|
||||
}
|
||||
else {
|
||||
pet = [[RVBPet alloc] initWithValues:[output asDictionary]];
|
||||
}
|
||||
}];
|
||||
|
||||
loopUntil = [NSDate dateWithTimeIntervalSinceNow:10];
|
||||
while(!done && [loopUntil timeIntervalSinceNow] > 0){
|
||||
if(gError){
|
||||
STFail(@"got error %@", gError);
|
||||
done = true;
|
||||
}
|
||||
if(pet){
|
||||
STAssertNotNil([pet _id], @"pet was nil");
|
||||
STAssertEqualObjects([pet name], @"programmer", @"pet name was not updated");
|
||||
STAssertEqualObjects([pet status], @"confused", @"pet status was not updated");
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
STAssertNotNil(pet, @"failed to fetch valid result in 10 seconds");
|
||||
}
|
||||
|
||||
- (void)testGetPetByStatus {
|
||||
bool done = false;
|
||||
static NSMutableArray* pets = nil;
|
||||
static NSError * gError = nil;
|
||||
[api findPetsByStatusWithCompletionBlock:@"available" completionHandler:^(NSArray *output, NSError *error) {
|
||||
if(error) {
|
||||
gError = error;
|
||||
}
|
||||
if(output == nil){
|
||||
NSLog(@"failed to fetch pets");
|
||||
}
|
||||
else {
|
||||
pets = [[NSMutableArray alloc]init];
|
||||
for(RVBPet* pet in output) {
|
||||
[pets addObject:[[RVBPet alloc] initWithValues:[pet asDictionary]]];
|
||||
}
|
||||
}
|
||||
}];
|
||||
NSDate * loopUntil = [NSDate dateWithTimeIntervalSinceNow:10];
|
||||
while(!done && [loopUntil timeIntervalSinceNow] > 0){
|
||||
if(gError){
|
||||
STFail(@"got error %@", gError);
|
||||
done = true;
|
||||
}
|
||||
if(pets){
|
||||
for(RVBPet * pet in pets) {
|
||||
STAssertEqualObjects([pet status], @"available", @"got invalid status for pets");
|
||||
}
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testGetPetByTags {
|
||||
bool done = false;
|
||||
static NSMutableArray* pets = nil;
|
||||
static NSError * gError = nil;
|
||||
[api findPetsByTagsWithCompletionBlock:@"tag1,tag2" completionHandler:^(NSArray *output, NSError *error) {
|
||||
if(error) {
|
||||
gError = error;
|
||||
}
|
||||
if(output == nil){
|
||||
NSLog(@"failed to fetch pets");
|
||||
}
|
||||
else {
|
||||
pets = [[NSMutableArray alloc]init];
|
||||
for(RVBPet* pet in output) {
|
||||
[pets addObject:[[RVBPet alloc] initWithValues:[pet asDictionary]]];
|
||||
}
|
||||
}
|
||||
}];
|
||||
NSDate * loopUntil = [NSDate dateWithTimeIntervalSinceNow:10];
|
||||
while(!done && [loopUntil timeIntervalSinceNow] > 0){
|
||||
if(gError){
|
||||
STFail(@"got error %@", gError);
|
||||
done = true;
|
||||
}
|
||||
if(pets){
|
||||
for(RVBPet * pet in pets) {
|
||||
bool hasTag = false;
|
||||
for(RVBTag * tag in [pet tags]){
|
||||
if([[tag name] isEqualToString:@"tag1"] || [[tag name] isEqualToString:@"tag2"])
|
||||
hasTag = true;
|
||||
}
|
||||
if(!hasTag) STFail(@"failed to find tag in pet");
|
||||
}
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@end
|
@ -1,22 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.wordnik.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
</dict>
|
||||
</plist>
|
@ -1,7 +0,0 @@
|
||||
//
|
||||
// Prefix header for all source files of the 'PetstoreClientTests' target in the 'PetstoreClientTests' project
|
||||
//
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#endif
|
@ -1,9 +0,0 @@
|
||||
#import <SenTestingKit/SenTestingKit.h>
|
||||
#import "RVBUserApi.h"
|
||||
|
||||
@interface UserApiTest : SenTestCase {
|
||||
@private
|
||||
RVBUserApi * api;
|
||||
}
|
||||
|
||||
@end
|
@ -1,47 +0,0 @@
|
||||
#import "UserApiTest.h"
|
||||
|
||||
@implementation UserApiTest
|
||||
|
||||
- (void)setUp {
|
||||
[super setUp];
|
||||
api = [[RVBUserApi alloc ]init];
|
||||
}
|
||||
|
||||
- (void)tearDown {
|
||||
[super tearDown];
|
||||
}
|
||||
|
||||
- (void)testLoginUser {
|
||||
bool done = false;
|
||||
static NSString* authString = nil;
|
||||
static NSError * gError = nil;
|
||||
|
||||
[api loginUserWithCompletionBlock:@"foo"
|
||||
password:@"bar"
|
||||
completionHandler:^(NSString *output, NSError *error) {
|
||||
if(error) {
|
||||
gError = error;
|
||||
}
|
||||
if(output == nil){
|
||||
NSLog(@"failed to login");
|
||||
}
|
||||
else {
|
||||
authString = [NSString stringWithString:output];
|
||||
}
|
||||
}];
|
||||
|
||||
NSDate * loopUntil = [NSDate dateWithTimeIntervalSinceNow:10];
|
||||
while(!done && [loopUntil timeIntervalSinceNow] > 0){
|
||||
if(gError){
|
||||
STFail(@"got error %@", gError);
|
||||
done = true;
|
||||
}
|
||||
if(authString){
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
STAssertTrue([authString length] > 0, @"string was zero chars");
|
||||
NSLog(@"got login %@", authString);
|
||||
}
|
||||
|
||||
@end
|
Loading…
x
Reference in New Issue
Block a user