mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	Since FIXTURE_DIR_NAME is the name of the folder that contains the view and tests modules of the webhook and another folder called "fixtures" that store the fixtures, it is more appropriate to call it WEBHOOK_DIR_NAME, especially when we want to refer to the view module using this variable.
		
			
				
	
	
		
			57 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			57 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
from zerver.lib.test_classes import WebhookTestCase
 | 
						|
 | 
						|
 | 
						|
class NetlifyHookTests(WebhookTestCase):
 | 
						|
    STREAM_NAME = "netlify"
 | 
						|
    URL_TEMPLATE = "/api/v1/external/netlify?stream={stream}&api_key={api_key}"
 | 
						|
    WEBHOOK_DIR_NAME = "netlify"
 | 
						|
 | 
						|
    def test_building_message(self) -> None:
 | 
						|
        expected_topic = "master"
 | 
						|
        expected_message = "The build [objective-jepsen-35fbb2](http://objective-jepsen-35fbb2.netlify.com) on branch master is now building."
 | 
						|
 | 
						|
        self.check_webhook(
 | 
						|
            "deploy_building", expected_topic, expected_message, content_type="application/json"
 | 
						|
        )
 | 
						|
 | 
						|
    def test_created_message(self) -> None:
 | 
						|
        expected_topic = "master"
 | 
						|
        expected_message = "The build [objective-jepsen-35fbb2](http://objective-jepsen-35fbb2.netlify.com) on branch master is now ready."
 | 
						|
 | 
						|
        self.check_webhook(
 | 
						|
            "deploy_created", expected_topic, expected_message, content_type="application/json"
 | 
						|
        )
 | 
						|
 | 
						|
    def test_failed_message(self) -> None:
 | 
						|
        expected_topic = "master"
 | 
						|
        expected_message = (
 | 
						|
            "The build [objective-jepsen-35fbb2](http://objective-jepsen-35fbb2.netlify.com) "
 | 
						|
            "on branch master failed during stage 'building site': Build script returned non-zero exit code: 127"
 | 
						|
        )
 | 
						|
 | 
						|
        self.check_webhook(
 | 
						|
            "deploy_failed", expected_topic, expected_message, content_type="application/json"
 | 
						|
        )
 | 
						|
 | 
						|
    def test_locked_message(self) -> None:
 | 
						|
        expected_topic = "master"
 | 
						|
        expected_message = (
 | 
						|
            "The build [objective-jepsen-35fbb2](http://objective-jepsen-35fbb2.netlify.com) "
 | 
						|
            "on branch master is now locked."
 | 
						|
        )
 | 
						|
 | 
						|
        self.check_webhook(
 | 
						|
            "deploy_locked", expected_topic, expected_message, content_type="application/json"
 | 
						|
        )
 | 
						|
 | 
						|
    def test_unlocked_message(self) -> None:
 | 
						|
        expected_topic = "master"
 | 
						|
        expected_message = (
 | 
						|
            "The build [objective-jepsen-35fbb2](http://objective-jepsen-35fbb2.netlify.com) "
 | 
						|
            "on branch master is now unlocked."
 | 
						|
        )
 | 
						|
 | 
						|
        self.check_webhook(
 | 
						|
            "deploy_unlocked", expected_topic, expected_message, content_type="application/json"
 | 
						|
        )
 |