Skip to content

Commit abfc7d8

Browse files
committed
Adding unit test for Hypervisor Model
1 parent d978238 commit abfc7d8

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
namespace OpenStack\Test\Compute\v2\Models;
4+
5+
use OpenStack\Compute\v2\Api;
6+
use OpenStack\Compute\v2\Models\Hypervisor;
7+
use OpenStack\Test\TestCase;
8+
9+
class HypervisorTest extends TestCase
10+
{
11+
/**@var Hypervisor */
12+
private $hypervisor;
13+
14+
const ID = 1;
15+
16+
public function setUp()
17+
{
18+
parent::setUp();
19+
20+
$this->rootFixturesDir = dirname(__DIR__);
21+
22+
$this->hypervisor = new Hypervisor($this->client->reveal(), new Api());
23+
$this->hypervisor->id = self::ID;
24+
}
25+
26+
public function test_it_retrieves()
27+
{
28+
$this->setupMock('GET', 'os-hypervisors/' . self::ID, null, [], 'hypervisor-get');
29+
30+
$this->hypervisor->retrieve();
31+
32+
$this->assertEquals('1', $this->hypervisor->id);
33+
$this->assertEquals('enabled', $this->hypervisor->status);
34+
$this->assertEquals('up', $this->hypervisor->state);
35+
36+
$this->assertEquals('146', $this->hypervisor->free_disk_gb);
37+
$this->assertEquals('76917', $this->hypervisor->free_ram_mb);
38+
$this->assertEquals('localhost.localdomain', $this->hypervisor->hypervisor_hostname);
39+
$this->assertEquals('QEMU', $this->hypervisor->hypervisor_type);
40+
$this->assertEquals('2006000', $this->hypervisor->hypervisor_version);
41+
$this->assertEquals('266', $this->hypervisor->local_gb);
42+
$this->assertEquals('120', $this->hypervisor->local_gb_used);
43+
$this->assertEquals('97909', $this->hypervisor->memory_mb);
44+
$this->assertEquals('20992', $this->hypervisor->memory_mb_used);
45+
$this->assertEquals('4', $this->hypervisor->running_vms);
46+
$this->assertEquals('56', $this->hypervisor->vcpus);
47+
$this->assertEquals('10', $this->hypervisor->vcpus_used);
48+
$this->assertEquals(['host' => 'localhost.localdomain', 'id' => '8', 'disabled_reason' => null], $this->hypervisor->service);
49+
}
50+
}

0 commit comments

Comments
 (0)