예제 #1
0
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)
예제 #2
0
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)
예제 #3
0
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)
예제 #4
0
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)
예제 #5
0
def when_i_send_a_new_micropost_with_an_attachment(step):
    note = Note(title="test note",
                content="test content",
                authorKey=world.browser2.user.key)
    note.save()

    data = dict()
    data["content"] = "test"
    data["tags"] = ["all"]
    data["attachments"] = [{"type": "Note", "id": note._id}]
    response = world.browser.post("microposts/all/", json_encode(data))
    assert 200 == response.code
예제 #6
0
def create_through_handler_a_note(step):
    world.note = Note(title="test note creation",
                      content="test content creation",
                      date=datetime.datetime.utcnow())
    response = client.post("notes/all/", body=world.note.toJson())
    noteDict = json_decode(response.body)
    world.note = Note(
        author=noteDict["author"],
        title=noteDict["title"],
        content=noteDict["content"],
        lastModified=date_util.convert_timezone_date_to_utc(
            date_util.get_date_from_db_date(noteDict["lastModified"])),
        isMine=noteDict["isMine"],
    )
    world.note._id = noteDict["_id"]
예제 #7
0
def when_i_send_a_new_micropost_with_an_attachment(step):
    note = Note(
        title="test note",
        content="test content",
        authorKey=world.browser2.user.key
    )
    note.save()

    data = dict()
    data["content"] = "test"
    data["tags"] = ["all"]
    data["attachments"] = [{
        "type": "Note",
        "id": note._id
    }]
    response = world.browser.post("microposts/all/", json_encode(data))
    assert 200 == response.code
예제 #8
0
def retrieve_through_handler_the_note_with_note_id(step):
    note = client.fetch_document("notes/all/" + world.note._id)
    world.test_note = Note(
        author=note["author"],
        title=note["title"],
        content=note["content"],
        lastModified=date_util.convert_timezone_date_to_utc(
            date_util.get_date_from_db_date(note["lastModified"])),
        isMine=note["isMine"],
    )
예제 #9
0
    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)
예제 #10
0
    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)
예제 #11
0
def create_a_note(step):
    world.note = Note(
        author="Owner",
        title="test note",
        content="test content",
    )