def testBaseSearchHost(self, getStubMock): stubMock = mock.Mock() stubMock.GetHosts.return_value = host_pb2.HostGetHostsResponse() getStubMock.return_value = stubMock hostSearch = opencue.search.HostSearch(substr=['unittest_host']) hostSearch.search() stubMock.GetHosts.assert_called_with(host_pb2.HostGetHostsRequest( r=host_pb2.HostSearchCriteria(substr=['unittest_host'])), timeout=mock.ANY)
def testGetHosts(self, getStubMock): stubMock = mock.Mock() stubMock.GetHosts.return_value = host_pb2.HostGetHostsResponse( hosts=host_pb2.HostSeq(hosts=[host_pb2.Host(name=TEST_HOST_NAME)])) getStubMock.return_value = stubMock hosts = opencue.api.getHosts(name=[TEST_HOST_NAME]) stubMock.GetHosts.assert_called_with( host_pb2.HostGetHostsRequest(r=host_pb2.HostSearchCriteria(hosts=[TEST_HOST_NAME])), timeout=mock.ANY) self.assertEqual(1, len(hosts)) self.assertEqual(TEST_HOST_NAME, hosts[0].name())