コード例 #1
0
ファイル: api_test.py プロジェクト: vasanth3045/discovery
 def test_get_no_hosts(self):
     registration = Registration()
     response, response_code = registration.get('foo')
     expected = {
         "hosts": [],
         "service": "foo",
         "env": "development"
     }
     assert response_code == 200
     assert response == expected
コード例 #2
0
ファイル: api_test.py プロジェクト: vvatsa/discovery
 def test_get_with_hosts(self, get_hosts):
     expected_hosts = [
         {
             'service': 'foo',
             'ip_address': '10.10.10.10',
             'service_repo_name': 'bar',
             'port': 10,
             'revision': 'blah',
             'last_check_in': 'timestamp',
             'tags': {
                 'az': 'woot',
                 'instance_id': 'wooooooooot'
             }
         },
         {
             'service': 'foo',
             'ip_address': '11.11.11.11',
             'service_repo_name': None,
             'port': 11,
             'revision': 'blah',
             'last_check_in': 'timestamp2',
             'tags': {
                 'az': 'woot',
                 'instance_id': 'wooooooooot'
             }
         },
     ]
     get_hosts.return_value = expected_hosts
     registration = Registration()
     registration._get_param = Mock(side_effect=self.generate_valid_params)
     response, response_code = registration.get('foo')
     expected = {
         "hosts": expected_hosts,
         "service": "foo",
         "env": "development"
     }
     assert response_code == 200
     assert response == expected