def test_get_aliases_with_alias_that_includes_parameter(self): with open(self.alias_file, 'a+') as f: f.write('my-alias = my-alias-value --my-parameter my-value') alias_interface = AliasLoader(self.alias_file) self.assertEqual( alias_interface.get_aliases(), {'my-alias': 'my-alias-value --my-parameter my-value'})
def test_get_aliases_with_multiple_aliases(self): with open(self.alias_file, "a+") as f: f.write("my-alias = my-alias-value\n") f.write("my-second-alias = my-second-alias-value\n") alias_interface = AliasLoader(self.alias_file) self.assertEqual( alias_interface.get_aliases(), {"my-alias": "my-alias-value", "my-second-alias": "my-second-alias-value"} )
def test_get_aliases_with_multiple_aliases(self): with open(self.alias_file, 'a+') as f: f.write('my-alias = my-alias-value\n') f.write('my-second-alias = my-second-alias-value\n') alias_interface = AliasLoader(self.alias_file) self.assertEqual( alias_interface.get_aliases(), {'my-alias': 'my-alias-value', 'my-second-alias': 'my-second-alias-value'})
def test_get_aliases_with_multiple_lines(self): with open(self.alias_file, "a+") as f: f.write("my-alias = \n" " my-alias-value \ \n" " --parameter foo\n") alias_interface = AliasLoader(self.alias_file) self.assertEqual( alias_interface.get_aliases(), # The backslash and newline should be preserved, but # still have the beginning and end newlines removed. {"my-alias": "my-alias-value \\\n--parameter foo"}, )
def test_get_aliases_with_multiple_lines(self): with open(self.alias_file, 'a+') as f: f.write('my-alias = \n' ' my-alias-value \ \n' ' --parameter foo\n') alias_interface = AliasLoader(self.alias_file) self.assertEqual( alias_interface.get_aliases(), # The backslash and newline should be preserved, but # still have the beginning and end newlines removed. {'my-alias': 'my-alias-value \\\n--parameter foo'})
def test_get_aliases_with_alias_that_is_indented(self): with open(self.alias_file, 'a+') as f: f.write('my-alias = \n my-alias-value\n') alias_interface = AliasLoader(self.alias_file) self.assertEqual(alias_interface.get_aliases(), {'my-alias': 'my-alias-value'})
def test_get_aliases_missing_toplevel(self): with open(self.alias_file, 'w') as f: f.write('[unrelated-section]\n') alias_interface = AliasLoader(self.alias_file) self.assertEqual(alias_interface.get_aliases(), {})
def test_get_aliases_empty_file(self): alias_interface = AliasLoader(self.alias_file) self.assertEqual(alias_interface.get_aliases(), {})
def test_get_aliases_non_existent_file(self): nonexistent_file = os.path.join(self.files.rootdir, 'no-exists') alias_interface = AliasLoader(nonexistent_file) self.assertEqual(alias_interface.get_aliases(), {})
def test_get_aliases_with_alias_that_is_indented(self): with open(self.alias_file, "a+") as f: f.write("my-alias = \n my-alias-value\n") alias_interface = AliasLoader(self.alias_file) self.assertEqual(alias_interface.get_aliases(), {"my-alias": "my-alias-value"})
def test_get_aliases_with_alias_that_includes_parameter(self): with open(self.alias_file, "a+") as f: f.write("my-alias = my-alias-value --my-parameter my-value") alias_interface = AliasLoader(self.alias_file) self.assertEqual(alias_interface.get_aliases(), {"my-alias": "my-alias-value --my-parameter my-value"})
def test_get_aliases_missing_toplevel(self): with open(self.alias_file, "w") as f: f.write("[unrelated-section]\n") alias_interface = AliasLoader(self.alias_file) self.assertEqual(alias_interface.get_aliases(), {})
def test_get_aliases_non_existent_file(self): nonexistent_file = os.path.join(self.files.rootdir, "no-exists") alias_interface = AliasLoader(nonexistent_file) self.assertEqual(alias_interface.get_aliases(), {})