Skip to content

added system_time endpoint #361

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 29, 2016
Merged

Conversation

SrinivasanTarget
Copy link
Member

@@ -15,6 +15,7 @@ module Device
device_locked?: 'session/:session_id/appium/device/is_locked'
},
get: {
get_device_time: 'session/:sessionId/appium/device/system_time',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should follow Ruby coding conventions and not use get prefixes in method names. So the better name would be device_time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering since all the other endpoints are session/:session_id but this one is session/:sessionId. Is this correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering since all the other endpoints are session/:session_id but this one is session/:sessionId. Is this correct?

@JaniJegoroff https://github.com/appium/node-mobile-json-wire-protocol/blob/master/lib/routes.js#L294 It should be "sessionId" not "session_id".

@bootstraponline What do you think about this? Quickly looking the code there's some kind of patching done for session_id's.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:sessionId is wrong. routes.js is JavaScript, not Ruby. Device methods in Ruby are specified like this:

session/:session_id/appium/device/

@bootstraponline
Copy link
Member

Hi, this should have a test.

@SrinivasanTarget
Copy link
Member Author

Will update the tests as well soon

@SrinivasanTarget
Copy link
Member Author

@bootstraponline @JaniJegoroff Could you please help me in tests i added, on what value i can assert the device date time?

@bootstraponline
Copy link
Member

Could you please help me in tests i added, on what value i can assert the device date time?

I'm assuming the date time is reported in a certain format that can be matched generically with the use of a regular expression.

@SrinivasanTarget
Copy link
Member Author

@bootstraponline But that changes with the time zone right? sample result: Fri Jan 29 23:53:35 IST 2016

@bootstraponline
Copy link
Member

> 'Fri Jan 29 23:53:35 IST 2016'.match /\d{2}:\d{2}:\d{2}/
=> #<MatchData "23:53:35">

All we care about is that the server returned something reasonable, it doesn't matter what. The actual device time tests should already exist in the appium node.js repo and hopefully they're mocking the device time.

@bootstraponline
Copy link
Member

This should work:

expect(device_time).to match(/\d{2}:\d{2}:\d{2}/)

@bootstraponline
Copy link
Member

Please squash to one commit.

git reset --soft head~5
git commit -am "Add device_time"
git push -f

@bayandin
Copy link
Contributor

Why not Date.parse(...)?

@SrinivasanTarget
Copy link
Member Author

Date.parse could again needs the regular expression.Both does the same right?

@bootstraponline
Copy link
Member

Why not Date.parse(...)?

because all we care about is that the server responded with something resembling a date. If the appium server is sending invalid dates then that should be detected by the JavaScript tests in the server repo, not the Ruby bindings. I don't think appium server has any guarantees that the returned date will work with Ruby's Date.parse.

The idea is for the test to be resilient if/when appium decides to change their date format.

@SrinivasanTarget
Copy link
Member Author

Squashed now @bootstraponline

@bootstraponline
Copy link
Member

Date.parse could again needs the regular expression.Both does the same right?

No, it doesn't need a regex.

> Date.parse 'Fri Jan 29 23:53:35 IST 2016'
=> #<Date: 2016-01-29 ((2457417j,0s,0n),+0s,2299161j)>

It means if appium gives us an invalid date then the Ruby test will fail, which I think is wrong. We're not testing that appium returns valid dates since that's beyond the scope of the client bindings.

@bootstraponline
Copy link
Member

Squashed now @bootstraponline

Looks good to me. Unless @bayandin has a good argument for why we should validate the date at the Ruby layer then I'm ready to merge.

@SrinivasanTarget
Copy link
Member Author

Ok Got it.Thanks @bootstraponline

@bayandin
Copy link
Contributor

@bootstraponline I'm completely agree with you, but it seems expect(device_time).to match(/\d{2}:\d{2}:\d{2}/) is more strict check than Date.parse(device_time). Maybe is enough just check that server returns a string.

@bootstraponline
Copy link
Member

it seems expect(device_time).to match(/\d{2}:\d{2}:\d{2}/) is more strict check than Date.parse(device_time)

oh, I didn't think of it like that. I agree Date.parse is better then.

Maybe is enough just check that server returns string.

I think we'll want to be more strict than just a string so we'll go with Date.parse. Thanks for commenting!

@SrinivasanTarget the test can be updated to just be Date.parse(device_time). If device time returns an invalid date then parse will raise an ArgumentError which will fail the test.

@bootstraponline
Copy link
Member

@SrinivasanTarget needs to be squashed to one commit :) then it'll be ready to merge.

@SrinivasanTarget
Copy link
Member Author

Yup Squashed @bootstraponline

bootstraponline added a commit that referenced this pull request Jan 29, 2016
@bootstraponline bootstraponline merged commit 92be077 into appium:master Jan 29, 2016
@bootstraponline
Copy link
Member

merged! Thanks for contributing to appium.

@SrinivasanTarget
Copy link
Member Author

Thanks @bootstraponline @bayandin

@bayandin
Copy link
Contributor

Just wondering, is there somewhere require 'date'? :)
@SrinivasanTarget thanks!

@SrinivasanTarget
Copy link
Member Author

Yes it has to be.Shit missed it.I saw in one example now!

@bootstraponline
Copy link
Member

Just wondering, is there somewhere require 'date'? :)

require 'date' is in the main Rakefile (which is used to run the tests). Not sure why it works since I'd expect it to have to be in the test Rakefile as well. It does work though, I ran the test. It looks like the endpoint isn't active in the server yet.

Selenium::WebDriver::Error::WebDriverError: unexpected response, code=404, content-type="text/plain"
That URL did not map to a valid JSONWP resource

I released 8.0.2 to Rubygems.

@bootstraponline
Copy link
Member

$ rake ios['device/device']
bundle exec ruby ./lib/run.rb ios "device/device"
Loading one test: /ruby_lib/ios_tests/lib/ios/specs/device/device.rb
device_time | 1 | specs/device/device.rb:3
  t 'device_time' do
    Date.parse 'Jan'
    Date.parse(device_time)


Finished in 0s

  1) Error:
device/device#test_0001_device_time:
Selenium::WebDriver::Error::WebDriverError: unexpected response, code=404, content-type="text/plain"
That URL did not map to a valid JSONWP resource

@SrinivasanTarget
Copy link
Member Author

What is the reason for this error @bootstraponline ?
Are we running in simulator?device_time on ios supports only real devices only

@bootstraponline
Copy link
Member

@SrinivasanTarget

The appium server doesn't recognize the endpoint.

info: --> GET /wd/hub/session/bdd2c145-2298-4a18-bad2-47618005a952/appium/device/system_time {}
info: [debug] Responding to client that we did not find a valid resource

@SrinivasanTarget
Copy link
Member Author

Usually how does an endpoint been activated in mjsonwp/appium?

@bootstraponline
Copy link
Member

My guess is the appium devs only added this new endpoint for appium 1.5 and it wasn't accepted into 1.4.

@SrinivasanTarget
Copy link
Member Author

Yes i raised PR only on 1.5 branch

@bootstraponline
Copy link
Member

ok, it should work in 1.5 then (I don't use that for testing hence the failure).

@SrinivasanTarget
Copy link
Member Author

Ok Thanks @bootstraponline

@SrinivasanTarget
Copy link
Member Author

will run in 1.5 and check

@JaniJegoroff
Copy link
Member

I don't see endpoint in 1.5 yet.

Janis-iMac:~ janijegoroff$ appium
[Appium] Welcome to Appium v1.5.0-beta11 (REV d19c85fa5aa8359ea81f5fbe8c3fe977b45ea526)
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
Janis-iMac:ios_tests janijegoroff$ arc
[1] pry(main)> device_time
Selenium::WebDriver::Error::UnknownError: Method has not yet been implemented

@bootstraponline
Copy link
Member

You probably need the latest revision from the 1.5 branch.

@JaniJegoroff
Copy link
Member

I tried against revision whatever is installed with command npm install -g appium@beta.

@bootstraponline
Copy link
Member

I think you'd have to use nightly and not beta.

@JaniJegoroff
Copy link
Member

Actually, it looks like beta is in sync with 1.5 branch commits.

@bootstraponline
Copy link
Member

really? d19c85fa5aa8359ea81f5fbe8c3fe977b45ea526 isn't the latest though.

@JaniJegoroff
Copy link
Member

I was looking the recent changes. I updated beta version and appium-android-driver@1.6.1 update was fetched: appium/appium@5661929

Janis-iMac:~ janijegoroff$ npm install -g appium@beta
npm WARN deprecated babel-core@5.8.24: Babel 5 is no longer being maintained. Upgrade to Babel 6.
/usr/local/bin/appium -> /usr/local/lib/node_modules/appium/build/lib/main.js
/usr/local/bin/authorize-ios -> /usr/local/lib/node_modules/appium/node_modules/.bin/authorize-ios
/usr/local/lib
└─┬ appium@1.5.0-beta11
  └── appium-android-driver@1.6.1

@bootstraponline
Copy link
Member

awesome! good to know that beta is tracking the 1.5 branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants