def test_resource_with_file_name(file_name, extension, expected): with patch('pybloqs.static.open', mock_open(read_data='Some content')) as mo: if extension is None: res = ps.Resource(file_name) else: res = ps.Resource(file_name, extension) # Check that file name used in open function is as expected assert os.path.basename(mo.call_args[0][0]) == expected assert res.name == 'test_file' assert res.content_string == 'Some content'
def test_resource_with_content_string(): r = ps.Resource(content_string='Some content', name='Some name') assert r.name == 'Some name' assert r.content_string == 'Some content'