Ejemplo n.º 1
0
def test_source_collection_ordering_with_multiple_draft_replies():
    # Create some test submissions, replies, and draft replies.
    source = factory.Source()
    file_1 = File(source=source, uuid="test", size=123, filename="1-test.doc.gpg",
                  download_url='http://test/test')
    message_2 = Message(source=source, uuid="test", size=123, filename="2-test.doc.gpg",
                        download_url='http://test/test')
    user = User(username='******')
    reply_3 = Reply(source=source, journalist=user, filename="3-reply.gpg",
                    size=1234, uuid='test')
    draft_reply_4 = DraftReply(uuid='4', source=source, journalist=user, file_counter=3,
                               timestamp=datetime.datetime(2000, 6, 6, 6, 0))
    draft_reply_5 = DraftReply(uuid='5', source=source, journalist=user, file_counter=3,
                               timestamp=datetime.datetime(2001, 6, 6, 6, 0))
    reply_6 = Reply(source=source, journalist=user, filename="4-reply.gpg",
                    size=1234, uuid='test2')
    draft_reply_7 = DraftReply(uuid='6', source=source, journalist=user, file_counter=4,
                               timestamp=datetime.datetime(2002, 6, 6, 6, 0))
    source.files = [file_1]
    source.messages = [message_2]
    source.replies = [reply_3, reply_6]
    source.draftreplies = [draft_reply_4, draft_reply_5, draft_reply_7]

    # Now these items should be in the source collection in the proper order
    assert source.collection[0] == file_1
    assert source.collection[1] == message_2
    assert source.collection[2] == reply_3
    assert source.collection[3] == draft_reply_4
    assert source.collection[4] == draft_reply_5
    assert source.collection[5] == reply_6
    assert source.collection[6] == draft_reply_7
Ejemplo n.º 2
0
def test_source_server_collection():
    # Create some test submissions and replies
    source = factory.Source()
    file_ = File(source=source, uuid="test", size=123, filename="2-test.doc.gpg",
                 download_url='http://test/test')
    message = Message(source=source, uuid="test", size=123, filename="3-test.doc.gpg",
                      download_url='http://test/test')
    user = User(username='******')
    reply = Reply(source=source, journalist=user, filename="1-reply.gpg",
                  size=1234, uuid='test')
    draft_reply = DraftReply(source=source, journalist=user,
                             uuid='test',
                             timestamp=datetime.datetime(2002, 6, 6, 6, 0))
    source.files = [file_]
    source.messages = [message]
    source.replies = [reply]
    source.draftreplies = [draft_reply]

    # Now these items should be in the source collection in the proper order
    assert source.server_collection[0] == reply
    assert source.server_collection[1] == file_
    assert source.server_collection[2] == message

    # Drafts do not appear in the server_collection, they are local only.
    assert draft_reply not in source.server_collection
Ejemplo n.º 3
0
def test_string_representation_of_draft_reply():
    user = User(username='******')
    source = factory.Source()
    draft_reply = DraftReply(source=source, journalist=user, uuid='test')
    draft_reply.__str__()
    draft_reply.content = "hello"
    draft_reply.__str__()
Ejemplo n.º 4
0
def test_repr_representation_of_draft_reply():
    user = User(username="******")
    source = factory.Source()
    draft_reply = DraftReply(source=source, journalist=user, uuid="test")
    draft_reply.__repr__()