Skip to content

Commit

Permalink
Ensure JobEfficiency realm is not shown in metric catalog (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpwhite4 authored and plessbd committed Sep 25, 2019
1 parent 046edc6 commit 9d038c3
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 0 deletions.
1 change: 1 addition & 0 deletions configuration/datawarehouse.d/jobefficiency.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"JobEfficiency": {
"schema": "N/A",
"table": "N/A",
"show_in_catalog": false,
"datasource": "SUPREMM",
"group_bys": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace IntegrationTests\Controllers;

class MetricExplorerControllerTest extends \PHPUnit_Framework_TestCase
{
/**
* Check that the SUPREMM realm shows in the metric explorer
* catalog and the JobEfficiency realm does not.
*/
public function testGetDwDescripter()
{
$helper = new \TestHarness\XdmodTestHelper();
$helper->authenticate('cd');

$response = $helper->post('/controllers/metric_explorer.php', null, array('operation' => 'get_dw_descripter'));

$this->assertEquals('application/json', $response[1]['content_type']);
$this->assertEquals(200, $response[1]['http_code']);

$dwdata = $response[0];

$this->assertArrayHasKey('SUPREMM', $dwdata['data']['0']['realms']);
$this->assertArrayNotHasKey('JobEfficiency', $dwdata['data']['0']['realms']);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace IntegrationTests\Controllers;

class UserInterfaceControllerTest extends \PHPUnit_Framework_TestCase
{
/**
* Check that the SUPREMM realm shows in the usage tab
* catalog and the JobEfficiency realm does not.
*/
public function testGetMenus()
{
$helper = new \TestHarness\XdmodTestHelper();
$helper->authenticate('cd');

$params = array(
'operation' => 'get_menus',
'node' => 'category_',
'public_user' => false,
'query_group' => 'tg_usage'
);

$response = $helper->post('/controllers/user_interface.php', null, $params);

$this->assertEquals('application/json', $response[1]['content_type']);
$this->assertEquals(200, $response[1]['http_code']);

$data = $response[0];

$realms = array();
foreach ($data as $menuitem) {
if (isset($menuitem['realm'])) {
if (!isset($realms[$menuitem['realm']])) {
$realms[$menuitem['realm']] = 0;
}
$realms[$menuitem['realm']] += 1;
}
}

$this->assertArrayHasKey('SUPREMM', $realms);
$this->assertArrayNotHasKey('JobEfficiency', $realms);

// The count represents the number of group bys in the realm
$this->assertTrue($realms['SUPREMM'] > 29);
}
}
62 changes: 62 additions & 0 deletions tests/integration_tests/lib/REST/Warehouse/DataTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

namespace IntegrationTests\REST\Warehouse;

class DataTest extends \PHPUnit_Framework_TestCase
{
protected static $xdmodhelper;

const ENDPOINT = 'rest/v0.1/warehouse/';

public static function setUpBeforeClass()
{
self::$xdmodhelper = new \TestHarness\XdmodTestHelper();
self::$xdmodhelper->authenticate('cd');
}

public static function tearDownAfterClass()
{
self::$xdmodhelper->logout();
}

public function testRealms() {

$response = self::$xdmodhelper->get(self::ENDPOINT . 'realms', array());

$this->assertEquals(200, $response[1]['http_code']);

$data = $response[0];
$this->assertTrue($data['success']);

$this->assertContains('SUPREMM', $data['results']);
$this->assertContains('JobEfficiency', $data['results']);
}

public function testAggregateData() {

$params = array(
'start' => 0,
'limit' => 10,
'config' => json_encode(array(
'realm' => 'JobEfficiency',
'group_by' => 'person',
'statistics' => array('core_time_bad', 'bad_core_ratio'),
'aggregation_unit' => 'day',
'start_date' => '2016-12-01',
'end_date' => '2017-01-01',
'order_by' => array('field' => 'core_time_bad', 'dirn' => 'desc')
))
);
$response = self::$xdmodhelper->get(self::ENDPOINT . 'aggregatedata', $params);

$this->assertEquals(200, $response[1]['http_code']);

$data = $response[0];
$this->assertArrayHasKey('success', $data);
$this->assertArrayHasKey('results', $data);
$this->assertArrayHasKey('total', $data);

$this->assertTrue($data['success']);
$this->assertEquals(min($data['total'], $params['limit']), count($data['results']));
}
}

0 comments on commit 9d038c3

Please sign in to comment.