Exemplo n.º 1
0
    def test_hosts_creation(self):
        """
        Verify Hosts model.
        """
        # Make sure hosts is required
        self.assertRaises(TypeError, hosts.Hosts)

        # Make sure an empty Hosts is still valid
        hosts_model = hosts.Hosts(hosts=[])
        self.assertEquals('[]', hosts_model.to_json())

        # Make sure a Host is accepted as expected
        hosts_model = hosts.Hosts(hosts=[
            hosts.Host(ssh_priv_key='dGVzdAo=',
                       address='127.0.0.1',
                       status='status',
                       os='atomic',
                       cpus=4,
                       memory=12345,
                       space=67890,
                       last_check='2016-01-07T15:09:29.944101')
        ])
        self.assertEquals(1, len(hosts_model.hosts))
        self.assertEquals(type(str()), type(hosts_model.to_json()))

        # Make sure other instances are not accepted
        hosts_model = hosts.Hosts(hosts=[object()])
Exemplo n.º 2
0
    def test_host_creation(self):
        """
        Verify host model
        """
        # Make sure it requires data
        self.assertRaises(TypeError, hosts.Host)

        # Make sure a Host creates expected results
        host_model = hosts.Host(ssh_priv_key='dGVzdAo=',
                                address='127.0.0.1',
                                status='status',
                                os='atomic',
                                cpus=4,
                                memory=12345,
                                space=67890,
                                last_check='2016-01-07T15:09:29.944101')
        self.assertEquals(type(str()), type(host_model.to_json()))