Compare commits
5 Commits
fd341bd9df
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 93ff836e08 | |||
| cd47d4aa84 | |||
| 2785d3d6b6 | |||
| f4732836ad | |||
| b0bd579357 |
27
.drone.yml
27
.drone.yml
@@ -6,17 +6,20 @@ steps:
|
|||||||
- name: build
|
- name: build
|
||||||
commands:
|
commands:
|
||||||
- docker-compose -p pycms build
|
- docker-compose -p pycms build
|
||||||
|
|
||||||
- name: test
|
|
||||||
commands:
|
|
||||||
- docker-compose -p pycms up --build --abort-on-container-exit
|
|
||||||
|
|
||||||
- name: push
|
|
||||||
commands:
|
|
||||||
- docker-compose -p pycms push
|
- docker-compose -p pycms push
|
||||||
- name: run
|
|
||||||
|
---
|
||||||
|
name: test
|
||||||
|
type: docker
|
||||||
|
kind: pipeline
|
||||||
|
steps:
|
||||||
|
- name: run db
|
||||||
|
image: mongo
|
||||||
|
detach: true
|
||||||
|
|
||||||
|
- name: run_tests
|
||||||
|
image: pycms_server
|
||||||
commands:
|
commands:
|
||||||
- docker-compose -p pycms down
|
- bash ./test.sh
|
||||||
- docker-compose -p pycms up -d
|
depends_on:
|
||||||
|
- build
|
||||||
|
|
||||||
15
main.py
15
main.py
@@ -101,19 +101,22 @@ class Back():
|
|||||||
return str(dict_posts)
|
return str(dict_posts)
|
||||||
|
|
||||||
def updatePost(self, name, body):
|
def updatePost(self, name, body):
|
||||||
# TODO: return RESTful error/success result
|
|
||||||
# If post exists, update it
|
# If post exists, update it
|
||||||
if posts.find_one({'name': name}):
|
if posts.find_one({'name': name}):
|
||||||
newPost = {'$set': {'text': body}}
|
newPostJson = {'$set': {'text': body}}
|
||||||
return str(posts.update_one({'name': name}, newPost))
|
newPost = posts.update_one({'name': name}, newPostJson)
|
||||||
|
result = dict(
|
||||||
|
status=200, state='updated', count=newPost.matched_count
|
||||||
|
)
|
||||||
# Else - create new
|
# Else - create new
|
||||||
else:
|
else:
|
||||||
newPost = {'name': name, 'text': body,
|
newPostJson = {'name': name, 'text': body,
|
||||||
'create_timestamp': str(time.time())}
|
'create_timestamp': str(time.time())}
|
||||||
return str(posts.insert_one(newPost).inserted_id)
|
newPost = posts.insert_one(newPostJson).inserted_id
|
||||||
|
result = dict(status=200, state='new')
|
||||||
|
return str(result)
|
||||||
|
|
||||||
def deletePost(self, name):
|
def deletePost(self, name):
|
||||||
# TODO: return RESTful error/success result
|
|
||||||
delete = posts.delete_one({'name': name}).deleted_count
|
delete = posts.delete_one({'name': name}).deleted_count
|
||||||
if not delete:
|
if not delete:
|
||||||
result = dict(status=500, count=delete)
|
result = dict(status=500, count=delete)
|
||||||
|
|||||||
2
test.sh
2
test.sh
@@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
curl_cmd='curl -w :%{http_code}'
|
curl_cmd='curl -s -w :%{http_code}'
|
||||||
#curl_cmd='curl -s -w "%{http_code}\t%{stdout}" -o /dev/null'
|
#curl_cmd='curl -s -w "%{http_code}\t%{stdout}" -o /dev/null'
|
||||||
url='server:8080'
|
url='server:8080'
|
||||||
$curl_cmd -X POST $url/admin/post/test -F 'body=testpage' && echo ": Create success" || echo ': create fail'
|
$curl_cmd -X POST $url/admin/post/test -F 'body=testpage' && echo ": Create success" || echo ': create fail'
|
||||||
|
|||||||
Reference in New Issue
Block a user