def test_default_publish(self): pact = Pact(self.consumer, self.provider, publish_to_broker=True, broker_base_url="http://localhost") pact.publish() self.mock_Popen.assert_called_once_with([ BROKER_CLIENT_PATH, 'publish', '--consumer-app-version=0.0.0', '--broker-base-url=http://localhost', 'TestConsumer-TestProvider.json'])
def test_manual_tagged_publish(self): pact = Pact(Consumer('TestConsumer', tags=['tag1', 'tag2']), self.provider, publish_to_broker=True, broker_base_url='http://localhost') pact.publish() self.mock_Popen.assert_called_once_with([ BROKER_CLIENT_PATH, 'publish', '--consumer-app-version=0.0.0', '--broker-base-url=http://localhost', 'TestConsumer-TestProvider.json', '-t', 'tag1', '-t', 'tag2' ])
def test_publish_fails(self): self.mock_Popen.return_value.returncode = 1 pact = Pact(self.consumer, self.provider, publish_to_broker=True, broker_base_url="http://localhost") with self.assertRaises(RuntimeError): pact.publish() self.mock_Popen.assert_called_once_with([ BROKER_CLIENT_PATH, 'publish', '--consumer-app-version=0.0.0', '--broker-base-url=http://localhost', 'TestConsumer-TestProvider.json'])
def test_basic_authenticated_publish(self): pact = Pact(self.consumer, self.provider, publish_to_broker=True, broker_base_url='http://localhost', broker_username='******', broker_password='******') pact.publish() self.mock_Popen.assert_called_once_with([ BROKER_CLIENT_PATH, 'publish', '--consumer-app-version=0.0.0', '--broker-base-url=http://localhost', '--broker-username=username', '--broker-password=password', 'TestConsumer-TestProvider.json' ])
def text_publish_with_broker_url_environment_variable(self): pact = Pact(self.consumer, self.provider, publish_to_broker=True) os.environ["PACT_BROKER_BASE_URL"] = "http://localhost" pact.publish() del os.environ["PACT_BROKER_BASE_URL"]
def test_publish_without_broker_url(self): pact = Pact(self.consumer, self.provider, publish_to_broker=True) with self.assertRaises(RuntimeError): pact.publish()