From bd1e3c44557103864b369922664cf82b2d5c7e31 Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Wed, 7 Feb 2018 14:35:36 +0100 Subject: [PATCH] Added test for checking popular shows list in tmdb. --- .../popular-show-success-response.json | 1 + .../system/asAUserIWantToGetPopularShows.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 seasoned_api/test/fixtures/popular-show-success-response.json create mode 100644 seasoned_api/test/system/asAUserIWantToGetPopularShows.js diff --git a/seasoned_api/test/fixtures/popular-show-success-response.json b/seasoned_api/test/fixtures/popular-show-success-response.json new file mode 100644 index 0000000..4faebbb --- /dev/null +++ b/seasoned_api/test/fixtures/popular-show-success-response.json @@ -0,0 +1 @@ +{"results":[{"title":"The Flash","year":2014,"type":"show","id":60735,"summary":"After a particle accelerator causes a freak storm, CSI Investigator Barry Allen is struck by lightning and falls into a coma. Months later he awakens with the power of super speed, granting him the ability to move through Central City like an unseen guardian angel. Though initially excited by his newfound powers, Barry is shocked to discover he is not the only \"meta-human\" who was created in the wake of the accelerator explosion -- and not everyone is using their new powers for good. Barry partners with S.T.A.R. Labs and dedicates his life to protect the innocent. For now, only a few close friends and associates know that Barry is literally the fastest man alive, but it won't be long before the world learns what Barry Allen has become...The Flash.","poster_path":"/lUFK7ElGCk9kVEryDJHICeNdmd1.jpg","background_path":"/mmxxEpTqVdwBlu5Pii7tbedBkPC.jpg","popularity":206.43201,"score":6.8},{"title":"The Big Bang Theory","year":2007,"type":"show","id":1418,"summary":"The Big Bang Theory is centered on five characters living in Pasadena, California: roommates Leonard Hofstadter and Sheldon Cooper; Penny, a waitress and aspiring actress who lives across the hall; and Leonard and Sheldon's equally geeky and socially awkward friends and co-workers, mechanical engineer Howard Wolowitz and astrophysicist Raj Koothrappali. The geekiness and intellect of the four guys is contrasted for comic effect with Penny's social skills and common sense.","poster_path":"/ooBGRQBdbGzBxAVfExiO8r7kloA.jpg","background_path":"/nGsNruW3W27V6r4gkyc3iiEGsKR.jpg","popularity":198.249769,"score":6.9},{"title":"The Face of Analia","year":2008,"type":"show","id":7859,"summary":"El Rostro de Analía is a Spanish-language telenovela produced by the American-based television network Telemundo. It stars Elizabeth Gutiérrez, Martin Karpan, Maritza Rodríguez and Gabriel Porras, with the special appearance of Gaby Espino. Written by Venezuelan writer Humberto \"Kiko\" Olivieri, the story is loosely based on María, María which starred Alba Roversi and Mexican soap star Arturo Peniche in Venezuela, and was also written by Olivieri. The novela is directed by David Posada and Danny Gaviria; with Jairo Arcila as General Producer and Aurelio Valcarcel Carrol as Executive Producer. Although the novela was set in Los Angeles, Telemundo filmed the serial in Miami, Fl. Through [sometimes not so] careful editing it was made to appear as Los Angeles. The network debuted it on October 20, 2008 at the 9 pm timeslot. Telemundo added English subtitles as closed captions on CC3 starting in March.\n\nRTV Pink started to air this telenovela on January 5, 2009 in Serbia. TVN started to air the telenovela on January 19, 2009 at the 8 pm timeslot. It debuted with the highest rating of a 2009 show in Panama. BTV started to air this telenovela on February 2, 2009 in Bulgaria. On February 25, 2009 it also debuted at 8pm on Canal 7 in Guatemala. From 31 August 2009, TV Puls plans to issue El Rostro de Analía on their TV channel in Poland at 15:30. In Albania, Top Channel airs the telenovela from Monday to Friday at 18:30. The show is airing on TV Doma in Slovakia from January 4, 2010 from Monday to Thursday at 20.50 as Pravá tvár vášne, in Romania from April 12, 2010 from Monday to Thursday at 21.30 as Cealalta fata an Analiei;from August 9 will be aired from Monday to Friday at 21.30. From 17 February 2010 RTL Croatia airs this telenovela from Monday to Friday at 14:00 as Drugo lice.","poster_path":"/mQJmZpHjKTsqt64PPGucObvU1gy.jpg","background_path":"/hQov6yy9ZHnM138UzJPvg9O018X.jpg","popularity":125.31485,"score":3.5},{"title":"Mindhunter","year":2017,"type":"show","id":67744,"summary":"An agent in the FBI's Elite Serial Crime Unit develops profiling techniques as he pursues notorious serial killers and rapists.","poster_path":"/zVuc3Sfs6gyJm6M6Iq52jqdavw4.jpg","background_path":"/a906PH7CDmSOdS7kmnAgdWk5mhv.jpg","popularity":122.613557,"score":7.4},{"title":"Supernatural","year":2005,"type":"show","id":1622,"summary":"When they were boys, Sam and Dean Winchester lost their mother to a mysterious and demonic supernatural force. Subsequently, their father raised them to be soldiers. He taught them about the paranormal evil that lives in the dark corners and on the back roads of America ... and he taught them how to kill it. Now, the Winchester brothers crisscross the country in their '67 Chevy Impala, battling every kind of supernatural threat they encounter along the way. ","poster_path":"/pui1V389cQft0BVFu9pbsYLEW1Q.jpg","background_path":"/o9OKe3M06QMLOzTl3l6GStYtnE9.jpg","popularity":122.131552,"score":7.2},{"title":"Arrow","year":2012,"type":"show","id":1412,"summary":"Spoiled billionaire playboy Oliver Queen is missing and presumed dead when his yacht is lost at sea. He returns five years later a changed man, determined to clean up the city as a hooded vigilante armed with a bow.","poster_path":"/mo0FP1GxOFZT4UDde7RFDz5APXF.jpg","background_path":"/dKxkwAJfGuznW8Hu0mhaDJtna0n.jpg","popularity":110.026609,"score":6},{"title":"Money Heist","year":2017,"type":"show","id":71446,"summary":"Spanish television series whose plot revolves around the perfect bank robbery - in this case, not only a bank, but the National Coinage and Stamp Factory, the Royal Mint of Spain.","poster_path":"/tADQv2ujTDMbiijSM4JELrY9tnF.jpg","background_path":"/wiBynY4ZUsklLlMlIQrFQoxByKu.jpg","popularity":106.835487,"score":7.9},{"title":"The Walking Dead","year":2010,"type":"show","id":1402,"summary":"Sheriff's deputy Rick Grimes awakens from a coma to find a post-apocalyptic world dominated by flesh-eating zombies. He sets out to find his family and encounters many other survivors along the way.","poster_path":"/vxuoMW6YBt6UsxvMfRNwRl9LtWS.jpg","background_path":"/xVzvD5BPAU4HpleFSo8QOdHkndo.jpg","popularity":103.579571,"score":7.4},{"title":"Marvel's Agents of S.H.I.E.L.D.","year":2013,"type":"show","id":1403,"summary":"Agent Phil Coulson of S.H.I.E.L.D. (Strategic Homeland Intervention, Enforcement and Logistics Division) puts together a team of agents to investigate the new, the strange and the unknown around the globe, protecting the ordinary from the extraordinary.","poster_path":"/xjm6uVktPuKXNILwjLXwVG5d5BU.jpg","background_path":"/qtr5i6hOm6oVzTYl3jOQAYP3oc7.jpg","popularity":100.53945,"score":6.7},{"title":"The Simpsons","year":1989,"type":"show","id":456,"summary":"Set in Springfield, the average American town, the show focuses on the antics and everyday adventures of the Simpson family; Homer, Marge, Bart, Lisa and Maggie, as well as a virtual cast of thousands. Since the beginning, the series has been a pop culture icon, attracting hundreds of celebrities to guest star. The show has also made name for itself in its fearless satirical take on politics, media and American life in general.","poster_path":"/yTZQkSsxUFJZJe67IenRM0AEklc.jpg","background_path":"/f5uNbUC76oowt5mt5J9QlqrIYQ6.jpg","popularity":91.912012,"score":7.1},{"title":"Doctor Who","year":2005,"type":"show","id":57243,"summary":"The Doctor looks and seems human. He's handsome, witty, and could be mistaken for just another man in the street. But he is a Time Lord: a 900 year old alien with 2 hearts, part of a gifted civilization who mastered time travel. The Doctor saves planets for a living – more of a hobby actually, and he's very, very good at it. He's saved us from alien menaces and evil from before time began – but just who is he?","poster_path":"/cFcZYgPRFZdBkA7EsxHz5Cb8x5.jpg","background_path":"/tQkigP2fItdzJWvtIhBvHxgs5yE.jpg","popularity":87.893522,"score":7},{"title":"Family Guy","year":1999,"type":"show","id":1434,"summary":"Sick, twisted, politically incorrect and Freakin' Sweet animated series featuring the adventures of the dysfunctional Griffin family. Bumbling Peter and long-suffering Lois have three kids. Stewie (a brilliant but sadistic baby bent on killing his mother and taking over the world), Meg (the oldest, and is the most unpopular girl in town) and Chris (the middle kid, he's not very bright but has a passion for movies). The final member of the family is Brian - a talking dog and much more than a pet, he keeps Stewie in check whilst sipping Martinis and sorting through his own life issues.","poster_path":"/gBGUL1UTUNmdRQT8gA1LUV4yg39.jpg","background_path":"/pH38r4TWTqq7Mcs6XAlwgzNUeJe.jpg","popularity":86.53606,"score":6.7},{"title":"Vikings","year":2013,"type":"show","id":44217,"summary":"Vikings follows the adventures of Ragnar Lothbrok, the greatest hero of his age. The series tells the sagas of Ragnar's band of Viking brothers and his family, as he rises to become King of the Viking tribes. As well as being a fearless warrior, Ragnar embodies the Norse traditions of devotion to the gods. Legend has it that he was a direct descendant of Odin, the god of war and warriors.","poster_path":"/oktTNFM8PzdseiK1X0E0XhB6LvP.jpg","background_path":"/A30ZqEoDbchvE7mCZcSp6TEwB1Q.jpg","popularity":83.461205,"score":7.4},{"title":"Grey's Anatomy","year":2005,"type":"show","id":1416,"summary":"Follows the personal and professional lives of a group of doctors at Seattle’s Grey Sloan Memorial Hospital.","poster_path":"/mgOZSS2FFIGtfVeac1buBw3Cx5w.jpg","background_path":"/y6JABtgWMVYPx84Rvy7tROU5aNH.jpg","popularity":83.185481,"score":6.2},{"title":"NCIS","year":2003,"type":"show","id":4614,"summary":"NCIS is an American police procedural drama television series, revolving around a fictional team of special agents from the Naval Criminal Investigative Service, which conducts criminal investigations involving the U.S. Navy and Marine Corps.","poster_path":"/1ubAPydzsb9VzhqeUGGDA7DZCUy.jpg","background_path":"/nymeWHYQ1JaWP2wyNW5a5WHiDCd.jpg","popularity":83.084046,"score":6.6},{"title":"Breaking Bad","year":2008,"type":"show","id":1396,"summary":"Breaking Bad is an American crime drama television series created and produced by Vince Gilligan. Set and produced in Albuquerque, New Mexico, Breaking Bad is the story of Walter White, a struggling high school chemistry teacher who is diagnosed with inoperable lung cancer at the beginning of the series. He turns to a life of crime, producing and selling methamphetamine, in order to secure his family's financial future before he dies, teaming with his former student, Jesse Pinkman. Heavily serialized, the series is known for positioning its characters in seemingly inextricable corners and has been labeled a contemporary western by its creator.","poster_path":"/1yeVJox3rjo2jBKrrihIMj7uoS9.jpg","background_path":"/bzoZjhbpriBT2N5kwgK0weUfVOX.jpg","popularity":82.291087,"score":8.3},{"title":"The Missing","year":2014,"type":"show","id":61555,"summary":"A gripping anthological relationship thriller series exploring the emotional fallout of a child's abduction not only on the family but on the wider community, told over two time frames.","poster_path":"/w1FDeOGoFS1qsSRHlj2Jzp2P0e1.jpg","background_path":"/2hF2RnjVwHvxfhH2lkB9H9FdQHb.jpg","popularity":80.13648,"score":7.3},{"title":"Supergirl","year":2015,"type":"show","id":62688,"summary":"Twenty-four-year-old Kara Zor-El, who was taken in by the Danvers family when she was 13 after being sent away from Krypton, must learn to embrace her powers after previously hiding them. The Danvers teach her to be careful with her powers, until she has to reveal them during an unexpected disaster, setting her on her journey of heroism.","poster_path":"/ufoGrTRbItHvqk42yNHcyoE0afM.jpg","background_path":"/lyA5Bw5paTzsVFGYHx3EbZNR9mK.jpg","popularity":74.295533,"score":5.6},{"title":"Game of Thrones","year":2011,"type":"show","id":1399,"summary":"Seven noble families fight for control of the mythical land of Westeros. Friction between the houses leads to full-scale war. All while a very ancient evil awakens in the farthest north. Amidst the war, a neglected military order of misfits, the Night's Watch, is all that stands between the realms of men and icy horrors beyond.","poster_path":"/gwPSoYUHAKmdyVywgLpKKA4BjRr.jpg","background_path":"/gX8SYlnL9ZznfZwEH4KJUePBFUM.jpg","popularity":72.329765,"score":8.1},{"title":"Friends","year":1994,"type":"show","id":1668,"summary":"Friends is an American sitcom revolving around a group of friends in the New York City borough of Manhattan. Episodes typically depict the friends' comedic and romantic adventures and career issues, such as Joey auditioning for roles or Rachel seeking jobs in the fashion industry. The six characters each have many dates and serious relationships, such as Monica with Richard Burke and Ross with Emily Waltham. Other frequently recurring characters include Ross and Monica's parents in Long Island, Ross's ex-wife and their son, Central Perk barista Gunther, Chandler's ex-girlfriend Janice, and Phoebe's twin sister Ursula.","poster_path":"/7buCWBTpiPrCF5Lt023dSC60rgS.jpg","background_path":"/efiX8iir6GEBWCD0uCFIi5NAyYA.jpg","popularity":71.73907,"score":7.8}],"page":1,"total_pages":1002,"total_results":20030} \ No newline at end of file diff --git a/seasoned_api/test/system/asAUserIWantToGetPopularShows.js b/seasoned_api/test/system/asAUserIWantToGetPopularShows.js new file mode 100644 index 0000000..f3e5185 --- /dev/null +++ b/seasoned_api/test/system/asAUserIWantToGetPopularShows.js @@ -0,0 +1,18 @@ +const assert = require('assert'); +const createCacheEntry = require('test/helpers/createCacheEntry'); +const resetDatabase = require('test/helpers/resetDatabase'); +const request = require('supertest-as-promised'); +const app = require('src/webserver/app'); +const popularShowsSuccess = require('test/fixtures/popular-show-success-response.json'); + +describe('As a user I want to get popular shows', () => { + before(() => resetDatabase()); + before(() => createCacheEntry('p:show::1', popularShowsSuccess)); + + it('should return 200 with the information', () => + request(app) + .get('/api/v1/tmdb/list/popular?type=show') + .expect(200) + .then(response => assert.equal(response.body.results.length, 20)) + ); +}); \ No newline at end of file