Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

import os 

import nose 

import shutil 

import yaml 

from picaxe import picaxe, cl_utils 

from picaxe.utKit import utKit 

import unittest 

 

from fundamentals import tools 

 

su = tools( 

arguments={"settingsFile": None}, 

docString=__doc__, 

logLevel="DEBUG", 

options_first=False, 

projectName="picaxe" 

) 

arguments, settings, log, dbConn = su.setup() 

 

# # load settings 

# stream = file( 

# "/Users/Dave/.config/picaxe/picaxe.yaml", 'r') 

# settings = yaml.load(stream) 

# stream.close() 

 

# SETUP AND TEARDOWN FIXTURE FUNCTIONS FOR THE ENTIRE MODULE 

moduleDirectory = os.path.dirname(__file__) 

utKit = utKit(moduleDirectory) 

log, dbConn, pathToInputDir, pathToOutputDir = utKit.setupModule() 

utKit.tearDownModule() 

 

# load settings 

stream = file( 

pathToInputDir + "/example_settings.yaml", 'r') 

settings = yaml.load(stream) 

stream.close() 

 

import shutil 

try: 

shutil.rmtree(pathToOutputDir) 

except: 

pass 

 

# Recursively create missing directories 

if not os.path.exists(pathToOutputDir): 

shutil.copytree(pathToInputDir, pathToOutputDir) 

 

 

testImage = pathToOutputDir + "/thespacedoctor_icon_dark_circle.png" 

 

# xt-setup-unit-testing-files-and-folders 

 

 

class test_picaxe(unittest.TestCase): 

 

# def test_picaxe_function(self): 

 

# from picaxe import picaxe 

# this = picaxe( 

# log=log, 

# settings=settings 

# ) 

# oauth_token, oauth_token_secret = this.authenticate() 

# print "oauth_token: ", oauth_token 

# print "oauth_token_secret: ", oauth_token_secret 

 

def test_direct_image_function(self): 

 

from picaxe import picaxe 

this = picaxe( 

log=log, 

settings=settings 

) 

this.get_photo_metadata( 

url="https://www.flickr.com/photos/92344016@N06/30455210086") 

this.get_photo_metadata( 

url="https://www.flickr.com/gp/92344016@N06/093pa6") 

images, title, desc, photoId = this.get_photo_metadata( 

url="http://flic.kr/p/NpdUV5") 

 

print images.keys 

 

def test_md_image_function(self): 

 

from picaxe import picaxe 

photo = picaxe( 

log=log, 

settings=settings 

) 

mdLink = photo.md( 

url="https://www.flickr.com/photos/92344016@N06/30455210086") 

print mdLink 

mdLink = photo.md( 

url="https://www.flickr.com/gp/92344016@N06/093pa6") 

print mdLink 

mdLink = photo.md(url="http://flic.kr/p/NpdUV5") 

print mdLink 

# https://c7.staticflickr.com/6/5493/30455210086_6685d6eb13_k.jpg 

# <a data-flickr-embed="true" href="https://www.flickr.com/gp/92344016@N06/pxQ3y1" title="Lion face"><img src="https://c7.staticflickr.com/6/5493/30455210086_6685d6eb13_k.jpg" width="2048" height="1356" alt="Lion face"></a><script async src="//embedr.flickr.com/assets/client-code.js" charset="utf-8"></script> 

 

def test_upload_local_image(self): 

 

from picaxe import picaxe 

photo = picaxe( 

log=log, 

settings=settings 

) 

photoid = photo.upload( 

imagePath=testImage, 

private=True, 

title="delete me", 

tags="nice, photo", 

description="this is thespacedoctor icon" 

) 

print photoid 

photoid = photo.upload( 

imagePath=testImage, 

private=False, 

title="delete me again", 

tags="crap, photo", 

description="this is thespacedoctor icon again", 

album="trash" 

) 

print photoid 

 

def test_add_image_to_album(self): 

 

from picaxe import picaxe 

flickr = picaxe( 

log=log, 

settings=settings 

) 

photoid = flickr.upload( 

imagePath=testImage, 

private=True, 

title="delete me", 

tags="nice, photo", 

description="this is thespacedoctor icon" 

) 

flickr._add_photo_to_album( 

photoId=photoid, 

album="trash" 

) 

 

def test_list_album_titles(self): 

 

from picaxe import picaxe 

flickr = picaxe( 

log=log, 

settings=settings 

) 

albumList = flickr.list_album_titles() 

print albumList 

 

def test_picaxe_function_exception(self): 

 

from picaxe import picaxe 

try: 

this = picaxe( 

log=log, 

settings=settings, 

fakeKey="break the code" 

) 

this.get() 

assert False 

except Exception, e: 

assert True 

print str(e) 

 

# x-print-testpage-for-pessto-marshall-web-object 

 

# x-class-to-test-named-worker-function