def test_key_list(self, tmpdir): """Should generate accurate key lists""" p = tmpdir.join(".env.yml") p.write(""" project: test environment: DEBUG: 1 ENVIRONMENT_NAME: development DATABASE_URL: sqlite:///simple.db NODE_NAME: localhost deployments: - DEBUG - sandbox: - ENVIRONMENT_NAME - DATABASE_URL - app_server: - NODE_NAME - worker: - NODE_NAME - DATABASE_URL """) r = readers.YAMLConfigReader(p) key_list = r.generate_key_list_for_resource("/test/sandbox/worker/") assert "/test/DEBUG" in key_list assert "/test/sandbox/ENVIRONMENT_NAME" in key_list assert "/test/sandbox/worker/NODE_NAME" in key_list assert "/test/sandbox/worker/DATABASE_URL" in key_list assert len(key_list) == 4
def test_read_multi_line_with_comment(self, tmpdir): """Should not clobber with commented values""" p = tmpdir.join(".env.yml") p.write(""" environment: ENVIRONMENT_NAME: development # ENVIRONMENT_NAME: not-development """) r = readers.YAMLConfigReader(p) env = r.read() assert "ENVIRONMENT_NAME" in env assert env["ENVIRONMENT_NAME"].preset == "development"
def test_read_single_line(self, tmpdir): """Should contain key name in result""" p = tmpdir.join(".env.yml") p.write(""" project: test environment: ENVIRONMENT_NAME: development """) r = readers.YAMLConfigReader(p) values = r.read() assert "ENVIRONMENT_NAME" in values
def test_read_single_line_with_comment(self, tmpdir): """Should not trip up on comments in file contents""" p = tmpdir.join(".env.yml") p.write(""" project: test environment: ENVIRONMENT_NAME: development # this is not part of the value """) r = readers.YAMLConfigReader(p) env = r.read() assert "ENVIRONMENT_NAME" in env assert env["ENVIRONMENT_NAME"].preset == "development"
def test_read_multi_line(self, tmpdir): """Should ignore whitespace and contain both key names in the result""" p = tmpdir.join(".env.yml") p.write(""" project: test environment: ENVIRONMENT_NAME: development DATABASE_URL: sqlite:///simple.db """) r = readers.YAMLConfigReader(p) values = r.read() assert "ENVIRONMENT_NAME" in values assert "DATABASE_URL" in values