def test_mask_with_this_url(self): """ Replace one url with another in a text string """ """ Test 1: No text to replace. No changes """ input_text = 'dddd anything http://www.example.com:8000 ' \ 'will get replaced' request = self.factory.get('/cmsblue/fhir/v1/Patient') response = mask_with_this_url(request, host_path='http://www.replaced.com', in_text='', find_url='http://www.example.com:8000') expected = '' self.assertEqual(response, expected) """ Test 2: No text to replace with. No changes """ input_text = 'dddd anything http://www.example.com:8000 ' \ 'will get replaced' request = self.factory.get('/cmsblue/fhir/v1/Patient') response = mask_with_this_url(request, host_path='http://www.replaced.com', in_text=input_text, find_url='') expected = input_text self.assertEqual(response, expected) """ Test 3: Replace text removing slash from end of replaced text """ input_text = 'dddd anything http://www.example.com:8000 ' \ 'will get replaced' request = self.factory.get('/cmsblue/fhir/v1/Patient') response = mask_with_this_url(request, host_path='http://www.replaced.com/', in_text=input_text, find_url='http://www.example.com:8000') expected = 'dddd anything http://www.replaced.com will get replaced' self.assertEqual(response, expected) """ Test 4: Replace text """ input_text = 'dddd anything http://www.example.com:8000 ' \ 'will get replaced' request = self.factory.get('/cmsblue/fhir/v1/Patient') response = mask_with_this_url(request, host_path='http://www.replaced.com', in_text=input_text, find_url='http://www.example.com:8000') expected = 'dddd anything http://www.replaced.com will get replaced' self.assertEqual(response, expected)
def test_mask_with_this_url(self): """ Replace one url with another in a text string """ """ Test 1: No text to replace. No changes """ input_text = "dddd anything http://www.example.com:8000 " "will get replaced" request = self.factory.get("/cmsblue/fhir/v1/Patient") response = mask_with_this_url( request, host_path="http://www.replaced.com", in_text="", find_url="http://www.example.com:8000" ) expected = "" self.assertEqual(response, expected) """ Test 2: No text to replace with. No changes """ input_text = "dddd anything http://www.example.com:8000 " "will get replaced" request = self.factory.get("/cmsblue/fhir/v1/Patient") response = mask_with_this_url(request, host_path="http://www.replaced.com", in_text=input_text, find_url="") expected = input_text self.assertEqual(response, expected) """ Test 3: Replace text removing slash from end of replaced text """ input_text = "dddd anything http://www.example.com:8000 " "will get replaced" request = self.factory.get("/cmsblue/fhir/v1/Patient") response = mask_with_this_url( request, host_path="http://www.replaced.com/", in_text=input_text, find_url="http://www.example.com:8000" ) expected = "dddd anything http://www.replaced.com will get replaced" self.assertEqual(response, expected) """ Test 4: Replace text """ input_text = "dddd anything http://www.example.com:8000 " "will get replaced" request = self.factory.get("/cmsblue/fhir/v1/Patient") response = mask_with_this_url( request, host_path="http://www.replaced.com", in_text=input_text, find_url="http://www.example.com:8000" ) expected = "dddd anything http://www.replaced.com will get replaced" self.assertEqual(response, expected)