gopro-plus 0.6.0.4 → 0.6.1.0
raw patch · 4 files changed
+30/−23 lines, 4 filesdep +tasty-discoverPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: tasty-discover
API changes (from Hackage documentation)
+ GoPro.Plus.Media: [_var_item_number] :: Variation -> Maybe Int
+ GoPro.Plus.Media: var_item_number :: Lens' Variation (Maybe Int)
- GoPro.Plus.Media: Variation :: Int -> Int -> String -> String -> Maybe [String] -> String -> String -> String -> Variation
+ GoPro.Plus.Media: Variation :: Int -> Int -> String -> String -> Maybe [String] -> Maybe Int -> String -> String -> String -> Variation
Files
- gopro-plus.cabal +5/−3
- src/GoPro/Plus/Media.hs +10/−9
- test/Main.hs +1/−0
- test/Spec.hs +14/−11
gopro-plus.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 3f64e72a9e9137f025a35d901ed752efe98124c39866a9b6a36b885d54ca9810+-- hash: 568ca727f101246b004f87ca33c63a764b181feb946f40ec1212abb44a2d8b58 name: gopro-plus-version: 0.6.0.4+version: 0.6.1.0 synopsis: GoPro Plus Client API. description: Please see the README on GitHub at <https://github.com/dustin/gopro-plus#readme> category: Web@@ -72,8 +72,9 @@ test-suite gopro-plus-test type: exitcode-stdio-1.0- main-is: Spec.hs+ main-is: Main.hs other-modules:+ Spec Paths_gopro_plus hs-source-dirs: test@@ -102,6 +103,7 @@ , raw-strings-qq , retry , tasty+ , tasty-discover , tasty-hunit , tasty-quickcheck , text
src/GoPro/Plus/Media.hs view
@@ -30,7 +30,7 @@ File(..), file_camera_position, file_height, file_width, file_item_number, file_orientation, file_head, file_url, file_transforms, Variation(..), var_height, var_width, var_label, var_quality,- var_type, var_transforms, var_head, var_url,+ var_type, var_transforms, var_head, var_url, var_item_number, SpriteFrame(..), frame_count, frame_height, frame_width, Sprite(..), sprite_fps, sprite_frame, sprite_height, sprite_width, sprite_type, sprite_heads, sprite_urls,@@ -244,14 +244,15 @@ toJSON = genericToJSON jsonOpts{ fieldLabelModifier = dropPrefix "_file_" } data Variation = Variation- { _var_height :: Int- , _var_width :: Int- , _var_label :: String- , _var_quality :: String- , _var_transforms :: Maybe [String]- , _var_type :: String- , _var_head :: String- , _var_url :: String+ { _var_height :: Int+ , _var_width :: Int+ , _var_label :: String+ , _var_quality :: String+ , _var_transforms :: Maybe [String]+ , _var_item_number :: Maybe Int+ , _var_type :: String+ , _var_head :: String+ , _var_url :: String } deriving (Generic, Eq, Show)
+ test/Main.hs view
@@ -0,0 +1,1 @@+{-# OPTIONS_GHC -F -pgmF tasty-discover -optF --tree-display #-}
test/Spec.hs view
@@ -1,6 +1,8 @@ {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE TypeApplications #-} +module Spec where+ import Control.Lens import qualified Data.Aeson as J import qualified Data.ByteString.Lazy as BL@@ -23,15 +25,15 @@ {"captured_at":"2020-04-06T00:33:22Z","content_title":null,"content_type":null,"created_at":"2020-04-06T01:39:39Z","gopro_user_id":"uid","file_size":7930021,"height":3000,"fov":null,"id":"EDavpqr4GVe8O","moments_count":0,"on_public_profile":false,"orientation":1,"play_as":"photo","ready_to_edit":true,"ready_to_view":"ready","resolution":"12000000","source_duration":"0","token":"token2","type":"Photo","width":4000}]}} |] -testSearchParser :: Assertion-testSearchParser = do+unit_searchParser :: Assertion+unit_searchParser = do let l = J.decode exampleMedia :: Maybe Listing assertEqual (show l) (Just (PageInfo 1 100 2169 22)) (l ^? _Just . pages) assertEqual (show l) [Video, Photo] (l ^.. _Just . media . folded . medium_type) assertEqual (show l) ["62NzWRrpPXm7o", "EDavpqr4GVe8O"] (l ^.. _Just . media . folded . medium_id) -testFileInfo :: Assertion-testFileInfo = do+unit_fileInfo :: Assertion+unit_fileInfo = do fi <- J.decode <$> BL.readFile "test/mediaex.json" :: IO (Maybe FileInfo) assertEqual (show fi) (Just "G0000004.JPG") (fi ^? _Just . filename) let Just fs = fi ^? _Just . fileStuff@@ -54,13 +56,17 @@ assertEqual (show fs) "intoalightpost" (fs ^. files . folded . file_transforms . folded . folded) +unit_concat :: Assertion+unit_concat = do+ fi <- J.decode <$> BL.readFile "test/concat.json" :: IO (Maybe FileInfo)+ let Just fs = fi ^? _Just . fileStuff+ assertEqual (show fi) [1, 2, 3] (fs ^.. variations . folded . var_item_number . _Just)+ propRTJSON :: (J.FromJSON j, J.ToJSON j, Eq j, Show j) => j -> Property propRTJSON = fromJust . J.decode . J.encode >>= (===) -tests :: [TestTree]-tests = [- testCase "Parsing" testSearchParser,- testCase "FileInfo" testFileInfo,+test_props :: [TestTree]+test_props = [ testGroup "JSON round tripping" $ [ testProperty "FileInfo" (propRTJSON @FileInfo), testProperty "Variation" (propRTJSON @Variation),@@ -76,6 +82,3 @@ testProperty "PageInfo" (propRTJSON @PageInfo) ] ]--main :: IO ()-main = defaultMain $ testGroup "All Tests" tests