<s> import os <EOL> from mock import patch <EOL> from django . test import TestCase <EOL> from django . conf import settings <EOL> from django . core . management import call_command <EOL> class TestSendWebhookFixtureMessage ( TestCase ) : <EOL> COMMAND_NAME = '<STR_LIT>' <EOL> def setUp ( self ) : <EOL> self . fixture_path = os . path . join ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . url = '<STR_LIT>' <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_check_if_command_exits_when_fixture_param_is_empty ( self , print_help_mock ) : <EOL> with self . assertRaises ( SystemExit ) : <EOL> call_command ( self . COMMAND_NAME , url = self . url ) <EOL> print_help_mock . assert_any_call ( '<STR_LIT>' , self . COMMAND_NAME ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_check_if_command_exits_when_url_param_is_empty ( self , print_help_mock ) : <EOL> with self . assertRaises ( SystemExit ) : <EOL> call_command ( self . COMMAND_NAME , fixture = self . fixture_path ) <EOL> print_help_mock . assert_any_call ( '<STR_LIT>' , self . COMMAND_NAME ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_check_if_command_exits_when_fixture_path_does_not_exist ( self , os_path_exists_mock ) : <EOL> os_path_exists_mock . return_value = False <EOL> with self . assertRaises ( SystemExit ) : <EOL> call_command ( self . COMMAND_NAME , fixture = self . fixture_path , url = self . url ) <EOL> os_path_exists_mock . assert_any_call ( os . path . join ( settings . DEPLOY_ROOT , self . fixture_path ) ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( "<STR_LIT>" , create = True ) <EOL> def test_check_if_command_post_request_to_url_with_fixture ( self , <EOL> open_mock , <EOL> ujson_mock , <EOL> client_mock , <EOL> os_path_exists_mock ) : <EOL> ujson_mock . loads . return_value = '<STR_LIT:{}>' <EOL> ujson_mock . dumps . return_value = { } <EOL> os_path_exists_mock . return_value = True <EOL> client = client_mock ( ) <EOL> call_command ( self . COMMAND_NAME , fixture = self . fixture_path , url = self . url ) <EOL> self . assertTrue ( ujson_mock . dumps . called ) <EOL> self . assertTrue ( ujson_mock . loads . called ) <EOL> self . assertTrue ( open_mock . called ) <EOL> client . post . assert_called_once_with ( self . url , { } , content_type = "<STR_LIT:application/json>" ) </s>
