Beispiel #1
0
    def test_post_valid_params(self):
        registration = Registration()
        registration._get_param = Mock(side_effect=self.generate_valid_params)
        response, response_code = registration.post('foo')
        expected = {}

        assert response_code == 200
        assert response == expected
Beispiel #2
0
    def test_post_invalid_params(self, get_param):
        get_param.return_value = '0'
        registration = Registration()
        response, response_code = registration.post('foo')
        expected = {}

        assert response_code == 400
        assert response == expected
Beispiel #3
0
 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
Beispiel #4
0
    def test_delete_success(self):
        registration = Registration()
        registration._get_param = Mock(side_effect=self.generate_valid_params)
        registration.post('foo')
        response, response_code = registration.delete('foo', '10.10.10.10')

        assert response_code == 200
        assert response == {}
Beispiel #5
0
 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
Beispiel #6
0
    def test_delete_invalid_ip_address(self):
        registration = Registration()
        response, response_code = registration.delete('foo', 'bar')

        assert response_code == 400
        assert response == {}
Beispiel #7
0
    def test_delete_nonexistent_missing_ip_address(self):
        registration = Registration()
        response, response_code = registration.delete('foo', None)

        assert response_code == 400
        assert response == {}
Beispiel #8
0
    def test_delete_nonexistent_host(self):
        registration = Registration()
        response, response_code = registration.delete('foo', '1.1.1.1')

        assert response_code == 400
        assert response == {}