def tzst_create_file_only(tmpdir): """ create a note with just a file (filename required). Creating a note with just a file and no title or text fails on the note being empty. After creating the note as here, there's no evidence of the file in the note. Aha! I was overwriting the file content with the file name. Let's try it again... Well, when I pass both file and filename, with the file content base64 encoded, what I get is 'File not in a valid base64 form'. It's not clear what the problem is. Guess I'll need to reach out to bear again. """ pytest.dbgfunc() cub = Bear() testfile = tmpdir.join("bear-test-data") # data = "".join(["This is a file for testing bear\n", # "It contains a couple of lines\n", # "and is going to be inserted into a bear note\n"]) data = "A" testfile.write(data) frob = base64.b64encode(data.encode()) note = cub.create(title=beartest_title(), file=frob, filename=testfile.strpath) if not note: pytest.fail("create returned empty result") cub.trash(id=note['identifier'])
def test_create_tttp(title, text, tags, ts): """ Test the create function with different possible arg combinations """ pytest.dbgfunc() cub = Bear() kw = {} if title: kw['title'] = title if text: kw['text'] = text if tags: kw['tags'] = tags if ts: kw['timestamp'] = ts note = cub.create(**kw) if not note: pytest.fail("create returned empty result") cub.trash(id=note['identifier'])