Skip to content
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

Merge Chullo and FedoraApi classes #70

Merged
merged 9 commits into from
Apr 21, 2017

Conversation

ruebot
Copy link
Member

@ruebot ruebot commented Apr 14, 2017

GitHub Issue: Resolves Islandora/documentation#601

What does this Pull Request do?

Merges Chullo and FedoraApi classes. Removes Chullo and IFedoraClient.

What's new?

getGraph utility function

How should this be tested?

Tests should take care of it. But, a good set of eyes from @dannylamb, @jonathangreen and @whikloj should really do it.

@codecov
Copy link

codecov bot commented Apr 14, 2017

Codecov Report

Merging #70 into master will increase coverage by 3.57%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master      #70      +/-   ##
============================================
+ Coverage      93.2%   96.77%   +3.57%     
+ Complexity       23       12      -11     
============================================
  Files             2        1       -1     
  Lines           103       62      -41     
============================================
- Hits             96       60      -36     
+ Misses            7        2       -5
Impacted Files Coverage Δ Complexity Δ
src/FedoraApi.php 96.77% <100%> (+1.31%) 12 <4> (+4) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f59f935...bf0a1ff. Read the comment docs.

$result = $client->createResource("");
$this->assertNull($result);
$result = $api->createResource("");
$this->assertEquals(404, $result->getStatusCode());
Copy link
Member Author

Choose a reason for hiding this comment

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

@whikloj raised a good question on his PR, are these useful any more? Maybe codecov will tell us?

Copy link
Member

Choose a reason for hiding this comment

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

As FedoraApi just returns the Response then a successful mocked request is as useful as a non-successful one. I think most of the ...returnsNullOtherwise and ...returnsFalseOtherwise tests could be dumped with no effect on code coverage.

Copy link
Member Author

Choose a reason for hiding this comment

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

@whikloj I'll do a test on one, and see what happens.

* @return \EasyRdf_Graph
*/
public function getGraph(ResponseInterface $response)
{
Copy link
Member Author

Choose a reason for hiding this comment

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

@dannylamb you want this to be parseGraph?

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe? I'll leave it to your judgement. If you think getGraph makes sense then its fine.

@ruebot
Copy link
Member Author

ruebot commented Apr 17, 2017

@whikloj looks like you're right. I'll reap some more code.

Copy link
Contributor

@dannylamb dannylamb left a comment

Choose a reason for hiding this comment

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

Can you make a createGraph that wraps createResource as well?

And some of these tests are getting a little meaningless, which I guess is a good thing. We really are just a thin wrapper at this point.

* @return \EasyRdf_Graph
*/
public function getGraph(ResponseInterface $response)
{
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe? I'll leave it to your judgement. If you think getGraph makes sense then its fine.

$options['body'] = $turtle;

// Save it.
return $this->client->request(
Copy link
Contributor

Choose a reason for hiding this comment

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

you can just call saveResource() here instead of setting the guzzle options manually

$options['body'] = $turtle;

// Save it.
return $this->saveResource($uri, $turtle);
Copy link
Member Author

Choose a reason for hiding this comment

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

@dannylamb I think this is right. It passes the test, but I'm not confident.

Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need the $options array at all, and you need to pass the headers in to saveResource()

$guzzle = new Client(['handler' => $handler]);
$api = new FedoraApi($guzzle);

$result = $api->createGraph(new \EasyRdf_Graph());
Copy link
Member

Choose a reason for hiding this comment

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

So this test raises a question, should we create a resource if the Graph is empty?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh boy. We probably shouldn't, and I can't think of reason why would want to do that. @dannylamb @jonathangreen thoughts?

Copy link
Contributor

@dannylamb dannylamb Apr 21, 2017

Choose a reason for hiding this comment

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

Good question. I'm thinking it's ok to create without content because it would be like an empty POST. But if the graph is empty we should probably just be passing NULL into createResource(). I don't actually know what a serialized empty graph in turtle will return. A blank string? Some prefix declarations?

Copy link
Contributor

Choose a reason for hiding this comment

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

This can also totally just be a follow up issue.

$this->assertFalse($result);
}
$result = $api->saveGraph(new \EasyRdf_Graph());
$this->assertEquals(204, $result->getStatusCode());
Copy link
Member

Choose a reason for hiding this comment

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

Same question as above, do we generate a resource on an empty graph or do we require some content before we persist it to the repository?

@dannylamb
Copy link
Contributor

I'm good with this. @whikloj @jonathangreen I'm comfortable merging if y'all are ok with it. I'll make a follow up issue to deal with empty graph behaviour.

@whikloj whikloj merged commit 7dcef92 into Islandora:master Apr 21, 2017
@ruebot ruebot deleted the issue-601 branch April 21, 2017 21:08
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.

3 participants