def tests_with_prefix_and_multiple_subjects(self): """ Tests the case that a line has a decorator and multiple subjects. For example: :: 127.0.0.1 google.com example.com example.net """ for domain in self.domains: expected = [domain, "example.com", "example.net"] data = f"0.0.0.0 {domain} example.com\t\texample.net" actual = File(data).get_converted() self.assertEqual(expected, actual) for domain in self.domains: expected = [domain, "example.com", "example.net"] data = f"127.0.0.1 {domain} example.com\t\texample.net" actual = File(data).get_converted() self.assertEqual(expected, actual)
def tests_with_prefix(self): """ Tests the case that a line has a decorator. For example: :: 127.0.0.1 google.com """ for domain in self.domains: expected = domain data = f"0.0.0.0 {domain}" actual = File(data).get_converted() self.assertEqual(expected, actual) for domain in self.domains: expected = domain data = f"127.0.0.1 {domain}" actual = File(data).get_converted() self.assertEqual(expected, actual)
def tests_simple_line(self): """ Tests the case that we encouter a simple line. """ for domain in self.domains: expected = domain actual = File(domain).get_converted() self.assertEqual(expected, actual)
def tests_with_list_of_entries(self): """ Tests the case that we give multiple entries """ given = [f"0.0.0.0\t\t\t\t\t\t\t\t\t\t{domain}" for domain in self.domains] expected = self.domains actual = File(given).get_converted() self.assertEqual(expected, actual)
def tests_comment(self): """ Tests the case that we encouter a commented line. """ for domain in self.domains: expected = None data = f"# {domain}" actual = File(data).get_converted() self.assertEqual(expected, actual)
def tests_with_multiple_tabs(self): """ Tests the case that we have multiple tabs as sparator between our domain end its prefix. """ for domain in self.domains: expected = domain data = f"0.0.0.0\t\t\t\t\t\t\t\t\t\t{domain}" actual = File(data).get_converted() self.assertEqual(expected, actual) for domain in self.domains: expected = domain data = f"127.0.0.1\t\t\t\t\t\t\t\t\t\t\t{domain}" actual = File(data).get_converted() self.assertEqual(expected, actual)
def tests_ends_with_comment(self): """ Tests the case that a line has a comment at the end of its line. """ for domain in self.domains: expected = domain data = f"{domain} # hello world" actual = File(data).get_converted() self.assertEqual(expected, actual)