Exemple #1
0
def test_create_note():
    conn = get_conn()
    note = Note.create(conn, note="This is a new note.", created_at = datetime.datetime.now())
    assert note.id == 1
    assert note.elapsed_seconds() < 0.01

    project = Project.create(
                conn,
                name = "My Project With Notes",
                created_at = datetime.datetime.now()
            )

    note2 = Note.create(
                conn,
                note="This is a note assigned to a project.",
                linked_to_type="Project",
                linked_to_id=project.id,
                created_at=datetime.datetime.now()
            )

    assert note2.id == 2

    inbox_notes = [n.id for n in Note.inbox(conn)]
    assert note.id in inbox_notes
    assert not note2.id in inbox_notes

    note.assign(conn, project)

    inbox_notes = [n.id for n in Note.inbox(conn)]
    assert not note.id in inbox_notes
    assert not note2.id in inbox_notes

    note = note.reload(conn)
    assert note.project(conn).id == project.id
    assert note2.project(conn).id == project.id
Exemple #2
0
def project_command(
    name=None,  # the name of the project (required)
    description="",  # an optional description for this project
    p=-1,  # portfolio id for this project (required unless parent project specified)
    parent=-1,  # parent project id, if this is a subproject
):
    """
    Create a new project.
    """
    c = conn()

    if parent > 0:
        parent_project_id = parent
        parent_project = Project.get(c, parent)
        portfolio_id = parent_project.portfolio_id
    else:
        parent_project_id = None
        if p > 0:
            portfolio_id = p
        else:
            raise Exception(
                "You must provide a portfolo id using the -p parameter if this project doesn't have a parent project."
            )

    project = Project.create(
        c,
        created_at=datetime.now(),
        description=description,
        parent_project_id=parent_project_id,
        name=name,
        portfolio_id=portfolio_id,
    )
    print project.id,
Exemple #3
0
def test_create_project():
    conn = get_conn()
    project = Project.create(conn, name="My New Project", created_at = datetime.datetime.now())
    assert project.id == 1
    assert project.elapsed_seconds() < 0.01

    lookup_project = Project.get(conn, 1)
    assert lookup_project.name == "My New Project"
    assert project.elapsed_seconds() < 0.01
Exemple #4
0
def test_persist_instance():
    conn = Model.setup_db()
    Project.create_table(conn)
    project = Project.create(conn, name="My New Project")
    print project.persist_instance_sql()
    print project.persist(conn)