Ejemplo n.º 1
0
 def parse_from_yaml(cls, source: Union[str, Path, IO]):
     "Parse from a path, url, path-like or file-like"
     with load_from_source(source) as (path, file):
         data = safe_load(file)
         return cls.parse_obj(data, path).__root__
Ejemplo n.º 2
0
    def test_load_from_path_string(self):
        import cumulusci

        p = Path(cumulusci.__file__).parent / "cumulusci.yml"
        with load_from_source(str(p)) as (filename, data):
            assert "tasks:" in data.read()
def _extract_names(source):
    with load_from_source(source) as (name, data):
        names = re.findall(r"[^\w_]([\w_]+__c)[^\w_]", data.read())
        return set(names)
Ejemplo n.º 4
0
 def test_load_from_url(self):
     html = "<!DOCTYPE HTML ..."
     responses.add("GET", "http://www.salesforce.com", body=html)
     with load_from_source("http://www.salesforce.com") as (filename, data):
         assert data.read() == html
Ejemplo n.º 5
0
 def test_writable_file_throws(self):
     with temporary_dir():
         with open("writable", "wt") as t:
             with pytest.raises(UnsupportedOperation):
                 with load_from_source(t) as (filename, data):
                     pass
Ejemplo n.º 6
0
 def test_binary_becomes_string(self):
     with load_from_source(BytesIO(b"foo")) as (path, file):
         data = file.read()
         assert isinstance(data, str)
         assert data == "foo"
Ejemplo n.º 7
0
 def test_load_from_fs_resource(self):
     p = Path(cumulusci.__file__).parent / "cumulusci.yml"
     with open_fs_resource(p) as p2:
         with load_from_source(p2) as (filename, data):
             assert "tasks:" in data.read()
Ejemplo n.º 8
0
 def test_load_from_open_file(self):
     p = Path(cumulusci.__file__).parent / "cumulusci.yml"
     with open(p) as f:
         with load_from_source(f) as (filename, data):
             assert "tasks:" in data.read()
             assert str(p) == filename