コード例 #1
0
 def test_should_read_variable(self):
     with NamedTemporaryFile(suffix="var.env") as tmp_file:
         tmp_file.write(b"KEY_A=VAL_A")
         tmp_file.flush()
         backend = LocalFilesystemBackend(variables_file_path=tmp_file.name)
         self.assertEqual("VAL_A", backend.get_variable("KEY_A"))
         self.assertIsNone(backend.get_variable("KEY_B"))
コード例 #2
0
 def test_should_read_connection(self):
     with NamedTemporaryFile(suffix=".env") as tmp_file:
         tmp_file.write(b"CONN_A=mysql://host_a")
         tmp_file.flush()
         backend = LocalFilesystemBackend(
             connections_file_path=tmp_file.name)
         assert ["mysql://host_a"] == [
             conn.get_uri() for conn in backend.get_connections("CONN_A")
         ]
         assert backend.get_variable("CONN_B") is None
コード例 #3
0
 def test_should_read_connection(self):
     with NamedTemporaryFile(suffix=".env") as tmp_file:
         tmp_file.write("CONN_A=mysql://host_a\nCONN_A=mysql://host_b".encode())
         tmp_file.flush()
         backend = LocalFilesystemBackend(connections_file_path=tmp_file.name)
         self.assertEqual(
             ["mysql://host_a", "mysql://host_b"],
             [conn.get_uri() for conn in backend.get_connections("CONN_A")],
         )
         self.assertIsNone(backend.get_variable("CONN_B"))
コード例 #4
0
 def test_files_are_optional(self):
     backend = LocalFilesystemBackend()
     self.assertEqual([], backend.get_connections("CONN_A"))
     self.assertIsNone(backend.get_variable("VAR_A"))
コード例 #5
0
 def test_files_are_optional(self):
     backend = LocalFilesystemBackend()
     assert [] == backend.get_connections("CONN_A")
     assert backend.get_variable("VAR_A") is None