def test_create_jam(client, user_token): rv = client.post( "/jams/", headers={"Authorization": user_token[1].token}, json={ "title": "test title for jam", "url": "test-jam", "description": "description", "short_description": "short", "start_date": datetime.datetime.now().timestamp() + 5, "end_date": datetime.datetime.now().timestamp() + 10, }, ) assert rv.json["success"] == 1 assert "jam" in rv.json blog = Blog.get() assert blog.creator == user_token[0], "Wrong creator" assert blog.description == 'Это блог для джема "test title for jam"' participiation = BlogParticipiation.get() assert participiation.user == user_token[0] assert participiation.role == 1, "Not owner on creation" jam = Jam.get() assert jam.creator == user_token[0], "Wrong creator" assert jam.title == "test title for jam" assert jam.url == "test-jam" assert jam.description == "description" assert jam.short_description == "short" assert int(jam.start_date) > int(datetime.datetime.now().timestamp()) assert int(jam.start_date) == int(jam.end_date - 5)
def test_create_blog(client, user_token): rv = client.post( "/blogs/", headers={"Authorization": user_token[1].token}, json={"url": "blog-url"}, ) assert rv.json["success"] == 1 assert "blog" in rv.json, "No blog in response" blog = Blog.get() assert blog.creator == user_token[0], "Wrong creator" assert blog.id == rv.json["blog"]["id"] participiation = BlogParticipiation.get() assert participiation.blog.id == rv.json["blog"]["id"] assert participiation.user == user_token[0] assert participiation.role == 1, "Not owner on creation"
def test_edit_jam(client, user_token, jam): rv = client.post( f"/jams/{jam.url}/", headers={"Authorization": user_token[1].token}, json={"title": "new title"}, ) assert rv.json["success"] == 1 assert "jam" in rv.json blog = Blog.get() assert blog.creator == user_token[0], "Wrong creator" assert blog.description == 'Это блог для джема "new title"' participiation = BlogParticipiation.get() assert participiation.user == user_token[0] assert participiation.role == 1, "Not owner on creation" jam = Jam.get() assert jam.creator == user_token[0], "Wrong creator" assert jam.title == "new title" assert jam.url == jam.url assert jam.description == jam.description assert jam.short_description == jam.short_description