Guest User

Untitled

a guest
Sep 19th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. import org.specs2.mutable._
  2.  
  3. import com.github.hexx.dispatch.tumblr._
  4.  
  5. class TumblrSpec extends Specification {
  6. import dispatch._
  7. import dispatch.json.Js
  8. import dispatch.json.JsHttp._
  9. import dispatch.oauth.{ Consumer, Token }
  10.  
  11. val consumer = Consumer("YOUR CONSUMER KEY", "YOUR CONSUMER SECRET")
  12. val username = "YOUR USERNAME"
  13. val password = "YOUR PASSWORD"
  14.  
  15. trait HttpAfter extends After {
  16. lazy val http = new Http
  17. lazy val access_token_xauth = http(Auth.access_token(consumer, username, password))
  18. def after = http.shutdown()
  19. }
  20.  
  21. "Blog Avatar" should {
  22. "pab-tech" in new HttpAfter {
  23. val req = Blog.avatar("pab-tech.tumblr.com")
  24. val res = http(req >:> (_("Content-Length")))
  25. res.head === "9001"
  26. }
  27. }
  28. "Blog Info" should {
  29. "pab-tech" in new HttpAfter {
  30. val res = http(Blog.info("pab-tech.tumblr.com", consumer))
  31. Blog.title(res) === "PAB@求職活動中"
  32. }
  33. }
  34. "Get Access Token via xAuth" should {
  35. "pab-tech" in new HttpAfter {
  36. access_token_xauth must beLike { case Token(_, _) => ok }
  37. }
  38. }
  39. "Blog Post" should {
  40. "pab-test" in new HttpAfter {
  41. // http(Blog.post("pab-test.tumblr.com", consumer, access_token_xauth, "type" -> "text", "title" -> "spec test title", "body" -> "spec test body"))
  42. success
  43. }
  44. }
  45. "User Dashboard" should {
  46. "pab-tech" in new HttpAfter {
  47. val res = http(User.dashboard(consumer, access_token_xauth))
  48. res.isEmpty must beFalse
  49. res map Post.timestamp forall (_.isInstanceOf[BigDecimal]) must beTrue
  50. }
  51. }
  52. }
Add Comment
Please, Sign In to add comment