TestRegistration.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env python2.6
  2. '''
  3. Licensed to the Apache Software Foundation (ASF) under one
  4. or more contributor license agreements. See the NOTICE file
  5. distributed with this work for additional information
  6. regarding copyright ownership. The ASF licenses this file
  7. to you under the Apache License, Version 2.0 (the
  8. "License"); you may not use this file except in compliance
  9. with the License. You may obtain a copy of the License at
  10. http://www.apache.org/licenses/LICENSE-2.0
  11. Unless required by applicable law or agreed to in writing, software
  12. distributed under the License is distributed on an "AS IS" BASIS,
  13. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. See the License for the specific language governing permissions and
  15. limitations under the License.
  16. '''
  17. from unittest import TestCase
  18. from ambari_agent.Register import Register
  19. import socket
  20. import os, pprint, json
  21. class TestRegistration(TestCase):
  22. def test_registration_build(self):
  23. register = Register()
  24. data = register.build(1)
  25. #print ("Register: " + pprint.pformat(data))
  26. self.assertEquals(len(data['hardwareProfile']) > 0, True, "hardwareProfile should contain content")
  27. self.assertEquals(data['hostname'] != "", True, "hostname should not be empty")
  28. self.assertEquals(data['publicHostname'] != "", True, "publicHostname should not be empty")
  29. self.assertEquals(data['responseId'], 1)
  30. self.assertEquals(data['timestamp'] > 1353678475465L, True, "timestamp should not be empty")
  31. self.assertEquals(len(data['agentEnv']) > 0, True, "agentEnv should not be empty")
  32. self.assertEquals(len(data), 6)