def beforeClass(cls): cls.identity = 'http://follower.example.com/tentd' cls.profile = 'http://follower.example.com/tentd/profile' cls.notification = 'http://follower.example.com/tentd/notification' cls.head = patch('requests.head', new_callable=MockFunction) cls.head.start() requests.head[cls.identity] = MockResponse( headers={'Link': '<{}>; rel="https://tent.io/rels/profile"'\ .format(cls.profile)}) cls.get = patch('requests.get', new_callable=MockFunction) cls.get.start() requests.get[cls.profile] = MockResponse( json={ "https://tent.io/types/info/core/v0.1.0": { "entity": cls.identity, "servers": ["http://follower.example.com/tentd"], "licences": [], "tent_version": "0.2", }}) cls.post = patch('requests.post', new_callable=MockFunction) cls.post.start() requests.post[cls.notification] = MockResponse()
def beforeClass(cls): cls.identity = 'http://follower.example.com/tentd' cls.profile = 'http://follower.example.com/tentd/profile' cls.notification = 'http://follower.example.com/tentd/notification' cls.head = patch('requests.head', new_callable=MockFunction) cls.head.start() requests.head[cls.identity] = MockResponse( headers={'Link': '<{}>; rel="https://tent.io/rels/profile"'\ .format(cls.profile)}) cls.get = patch('requests.get', new_callable=MockFunction) cls.get.start() requests.get[cls.profile] = MockResponse( json={ "https://tent.io/types/info/core/v0.1.0": { "entity": cls.identity, "servers": ["http://follower.example.com/tentd"], "licences": [], "tent_version": "0.2", } }) cls.post = patch('requests.post', new_callable=MockFunction) cls.post.start() requests.post[cls.notification] = MockResponse()
def beforeClass(self): """Set up details of followers.""" # Urls used for the follower self.identity = 'http://follower.example.com' self.profile = 'http://follower.example.com/tentd/profile' self.notification = 'http://follower.example.com/tentd/notification' # Urls used to update the follower self.new_identity = 'http://changed.follower.example.com' self.new_profile = 'http://follower.example.com/new/profile' # Mocks for the server responses self.head = patch('requests.head', new_callable=MockFunction) self.head.start() profile_response = MockResponse( headers={'Link': '<{}>; rel="https://tent.io/rels/profile"'\ .format(self.profile)}) new_profile_response = MockResponse( headers={'Link': '<{}>; rel="https://tent.io/rels/profile"'\ .format(self.new_profile)}) requests.head[self.identity] = profile_response requests.head[self.new_identity] = new_profile_response self.get = patch('requests.get', new_callable=MockFunction) self.get.start() requests.get[self.notification] = MockResponse() requests.get[self.profile] = MockResponse( json={ "https://tent.io/types/info/core/v0.1.0": { "entity": self.identity, "servers": ["http://follower.example.com/tentd"], "licences": [], "tent_version": "0.2", } }) requests.get[self.new_profile] = MockResponse( json={ "https://tent.io/types/info/core/v0.1.0": { "entity": self.new_identity, "servers": ["http://follower.example.com/tentd"], "licences": [], "tent_version": "0.2", } })
def beforeClass(self): """Set up details of followers.""" # Urls used for the follower self.identity = 'http://follower.example.com' self.profile = 'http://follower.example.com/tentd/profile' self.notification = 'http://follower.example.com/tentd/notification' # Urls used to update the follower self.new_identity = 'http://changed.follower.example.com' self.new_profile = 'http://follower.example.com/new/profile' # Mocks for the server responses self.head = patch('requests.head', new_callable=MockFunction) self.head.start() profile_response = MockResponse( headers={'Link': '<{}>; rel="https://tent.io/rels/profile"'\ .format(self.profile)}) new_profile_response = MockResponse( headers={'Link': '<{}>; rel="https://tent.io/rels/profile"'\ .format(self.new_profile)}) requests.head[self.identity] = profile_response requests.head[self.new_identity] = new_profile_response self.get = patch('requests.get', new_callable=MockFunction) self.get.start() requests.get[self.notification] = MockResponse() requests.get[self.profile] = MockResponse( json={ "https://tent.io/types/info/core/v0.1.0": { "entity": self.identity, "servers": ["http://follower.example.com/tentd"], "licences": [], "tent_version": "0.2", }}) requests.get[self.new_profile] = MockResponse( json={ "https://tent.io/types/info/core/v0.1.0": { "entity": self.new_identity, "servers": ["http://follower.example.com/tentd"], "licences": [], "tent_version": "0.2", }})