Added test scenarios for relative quota amount of personal space

This commit is contained in:
Roshan Lamichhane committed 2023-02-07 12:59:55 +05:45
1 parent f627499f95
commit 4e69478625
2 files changed
+50

No files matched your search

@@ -65,3 +65,24 @@ Feature: State of the quota
And user "Alice" has uploaded a file inside space "Project Delta" with content "7 bytes" to "test.txt"
When user "Alice" uploads a file inside space "Project Delta" with content "00011 bytes" to "test.txt" using the WebDAV API
Then the HTTP status code should be "507"
Scenario Outline: Check the relative amount of quota of personal space
Given user "Admin" has changed the quota of the personal space of "Alice Hansen" space to "10000"
And user "Alice" has uploaded file "<file_upload>" to "/demo.txt"
When the user "Alice" requests these endpoints with "GET" with basic auth
| endpoint |
| <end_point> |
Then the HTTP status code should be "200"
And the json responded should contain these key and value pairs:
| key | value |
| quota@@@free | <quota_free> |
| quota@@@used | <quota_used> |
| quota@@@total | <quota_total> |
| quota@@@relative | <quota_relative> |
Examples:
| file_upload | end_point | quota_free | quota_used | quota_total | quota_relative |
| /filesForUpload/lorem.txt | /ocs/v1.php/cloud/users/Alice?format=json | 9301 | 699 | 10000 | 6.99 |
| /filesForUpload/lorem-big.txt | /ocs/v1.php/cloud/users/Alice?format=json | 883 | 9117 | 10000 | 91.17 |
| /filesForUpload/lorem.txt | /ocs/v2.php/cloud/users/Alice?format=json | 9301 | 699 | 10000 | 6.99 |
| /filesForUpload/lorem-big.txt | /ocs/v2.php/cloud/users/Alice?format=json | 883 | 9117 | 10000 | 91.17 |
@@ -3134,4 +3134,33 @@ class SpacesContext implements Context {
)
);
}
/**
* @Then /^the json responded should contain these key and value pairs:$/
*
* Loops through data items in response to find given key and value pairs
* It does not support field value replacing
*
* @param TableNode $table
*
* @return void
* @throws Exception
*/
public function theJsonRespondedShouldContainTheseKeyAndValuePairs(TableNode $table):void {
$this->featureContext->verifyTableNodeColumns($table, ['key', 'value']);
$response = json_decode((string)$this->featureContext->getResponse()->getBody(), true, 512, JSON_THROW_ON_ERROR);
$data = $response["ocs"]["data"];
foreach ($table->getHash() as $row) {
$key = $row['key'];
$expectedValue = $row['value'];
$segments = explode('@@@', $key);
$actualValue = $data;
foreach ($segments as $segment) {
$arrayKeyExists = \array_key_exists($segment, $actualValue);
Assert::assertTrue($arrayKeyExists, "The key $segment does not exist on the response");
$actualValue = $actualValue[$segment];
}
Assert::assertEquals($expectedValue, $actualValue, "Expected $expectedValue but received $actualValue");
}
}
}