def creates_x_notes(step, nb_notes): world.notes = [] for i in range(int(nb_notes)): note = Note( author = "Owner %d" % i, title = "test note %d" % (int(nb_notes) - i), content = "test content %d" % i, ) note.save() world.notes.append(note)
def creates_at_different_times_x_notes(step, nb_notes): world.notes = [] for i in range(int(nb_notes)): note = Note( author = "Owner %d" % i, title = "test note %d" % i, content = "test content %d" % i, ) note.save() world.notes.append(note) time.sleep(2)
def when_i_send_a_new_micropost_with_an_attachment(step): note = Note( title="test note", content="test content", authorKey=world.browser2.user ) note.save() data = dict() data["content"] = "test attach" data["attachments"] = [{ "type": "Note", "id": note._id }] response = world.browser.post("microposts/all/", json_encode(data)) assert 200 == response.code
def post(self): ''' Creates a new note from received data. ''' logger.info("Note creation received.") data = self.get_body_as_dict(expectedFields=["title", "content"]) if data: note = Note( author = UserManager.getUser().name, title = data["title"], content = data["content"], isMine = True, ) note.save() self.create_owner_creation_activity(note, "writes", "note") self.return_one_document(note, 201) else: self.return_failure("No data sent", 400)