Exemple #1
0
def and_this_micropost_has_same_date_as_the_posted_one(step, timezone):
    micropost = world.microposts[0]

    posted_date = date_util.get_date_from_db_date(world.date_micropost["date"])
    posted_date = date_util.convert_timezone_date_to_utc(posted_date)

    tz = pytz.timezone(timezone)
    contact_date = date_util.get_date_from_db_date(micropost["date"])
    contact_date = date_util.convert_timezone_date_to_utc(contact_date, tz)

    assert_equals(contact_date, posted_date)
Exemple #2
0
def and_this_micropost_has_same_date_as_the_posted_one(step, timezone):
    micropost = world.microposts[0]
    
    posted_date = date_util.get_date_from_db_date(world.date_micropost["date"])
    posted_date = date_util.convert_timezone_date_to_utc(posted_date)

    tz = pytz.timezone(timezone)
    contact_date = date_util.get_date_from_db_date(micropost["date"])
    contact_date = date_util.convert_timezone_date_to_utc(contact_date, tz)

    assert contact_date == posted_date
Exemple #3
0
def then_my_activity_date_is_converted_to_my_timezone(step):
    assert 0 < len(world.data)
    date = world.data[0].get("date")
    date = date_util.get_date_from_db_date(date)
    date = date_util.convert_timezone_date_to_utc(date)

    assert world.activity.date.replace(tzinfo=pytz.utc) == date, date
Exemple #4
0
def checks_that_dict_convert_date_to_the_current_time_zone(step):
    lastModifiedDate = world.note.lastModified.replace(tzinfo=pytz.utc)
    lastModifiedDictDate = world.note.toDict()["lastModified"]
    lastModifiedDictDate = date_util.get_date_from_db_date(lastModifiedDictDate)
    lastModifiedDictDate = date_util.convert_timezone_date_to_utc(lastModifiedDictDate)

    assert lastModifiedDate == lastModifiedDictDate
Exemple #5
0
def and_this_micropost_has_timezone_date(step):
    world.date_micropost = world.microposts[-1]
    db_micropost = MicroPostManager.get_micropost(world.date_micropost["_id"])

    date = date_util.get_date_from_db_date(world.date_micropost["date"])

    assert db_micropost.date.replace(tzinfo=pytz.utc) == \
        date_util.convert_timezone_date_to_utc(date)
Exemple #6
0
def and_this_micropost_has_timezone_date(step):
    world.date_micropost = world.microposts[0]
    db_micropost = MicroPostManager.get_micropost(world.date_micropost["_id"])
    
    date = date_util.get_date_from_db_date(world.date_micropost["date"])
    
    assert db_micropost.date.replace(tzinfo=pytz.utc) == \
        date_util.convert_timezone_date_to_utc(date)
Exemple #7
0
def checks_that_dict_convert_date_to_the_current_time_zone(step):
    lastModifiedDate = world.note.lastModified.replace(tzinfo=pytz.utc)
    lastModifiedDictDate = world.note.toDict()["lastModified"]
    lastModifiedDictDate = \
        date_util.get_date_from_db_date(lastModifiedDictDate)
    lastModifiedDictDate = \
        date_util.convert_timezone_date_to_utc(lastModifiedDictDate)

    assert lastModifiedDate == lastModifiedDictDate
Exemple #8
0
def retrieve_through_handler_the_note_with_note_id(step):
    note = client.fetch_document("notes/" + 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"],
    )
Exemple #9
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"],
    )
Exemple #10
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"]
Exemple #11
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"]
Exemple #12
0
def when_i_convert_2011_02_01_13_45_32_to_utc_date(step, db_date):
    date = date_util.get_date_from_db_date(db_date)
    world.date = date_util.convert_timezone_date_to_utc(date)
Exemple #13
0
def when_i_convert_2011_02_01_13_45_32_to_utc_date(step, db_date):
    date = date_util.get_date_from_db_date(db_date)
    world.date = date_util.convert_timezone_date_to_utc(date)
Exemple #14
0
def then_dict_date_field_is_the_timezone_date(step):
    date = world.user.toDict().get("date")
    date = date_util.get_date_from_db_date(date)
    date = date_util.convert_timezone_date_to_utc(date)

    assert world.user.date.replace(tzinfo=pytz.utc) == date
Exemple #15
0
def then_dict_date_field_is_the_timezone_date(step):
    date = world.user.toDict().get("date")
    date = date_util.get_date_from_db_date(date)
    date = date_util.convert_timezone_date_to_utc(date)

    assert world.user.date.replace(tzinfo=pytz.utc) == date