Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
$ python tests/api_books_test.py
* GET /api/2/books
- [pass] returns list of books.
- [Fail] accepts 'size' parameter.
---...
class BooksAPI_Test(TestCase):
with subject("/api/v1/books"):
@test("accepts 'size' parameter.")
def _(self, api):
qs = "s...
$ ls app/**/*.py | wc -l
123
$ ls app/api/**.py | wc -l
23
$ ls app/models/**.py | wc -l
45
$ ls app/usecases/**.py | wc -...
GET /api/v1/books
class BooksAPI
def do_list()
class BooksService
def find_books()
class BookService(Service):
def find_books(self, **kwargs):
q = db.query(Book)
order = kwargs.pop('order')
if order: q = q...
class BookService(Service):
def find_books(self, **kwargs):
q = db.query(Book)
order = kwargs.pop('order')
if order: q = q...
class BooksAPI_Test(TestCase):
with subject("/api/v1/books"):
@test("[!mf7cw] accepts 'size' parameter.")
def _(self, api)...
$ python tests/api_books_test.py
* GET /api/2/books
- [pass] returns list of books.
- [Fail] accepts 'size' parameter.
---...
## -n: -r:
$ grep -nr mf7cw app
app/services/book_service.py:199: #; [!mf7cw]
accepts 'size' parameter.
## file: app/services/book_service.py
194: class BookService(Service):
195: def find_books(self, **kwargs):
196: q = db.qu...
$ less /var/log/postgresql/pg9.3-main.log
2016-12-01 12:34:56 JST [46212]
LOG: duration: 2671.751 ms
statement:
select * f...
$ ls app/**/*.py | wc -l
123
$ ls app/api/**.py | wc -l
23
$ ls app/models/**.py | wc -l
45
$ ls app/usecases/**.py | wc -...
sql = """
/* [sql:dolxq] */
select *
from books
where title like :pattern
order by title
limit :limit
"""
vars = {"title":...
2016-12-01 12:34:56 JST [46212]
LOG: duration: 2671.751 ms
statement:
/* [sql:dolxq] */
select * from books
where title li...
## grep ag (SilverSearcher)
$ ag dolxq app
app/services/book_service.py
79: /* [sql:dolxq] */
## file: app/services/book_service.py
78: sql = """
79: /* [sql:dolxq] */
80: select *
81: from books
82: where title like...
<p>
<form>
Name: <input name="name">
Comment: <input name="comment">
<input type="submit">
</form>
</p>
$ ls app/**/*.html* | wc -l
302
$ ls app/**/*.py | wc -l
123
<!-- [!v5ozp] -->
<p>
<form>
Name: <input name="name">
Comment: <input name="comment">
<input type="submit">
</form>
</p>
<p data-eid="!v5ozp">
<form>
Name: <input name="name">
Comment: <input name="comment">
<input type="submit">
</form>
</p>
<!-- [!v5ozp] -->
<p>
<form>
Name: <input name="name">
Comment: <input name="comment">
<input type="submit">
</form>
</p>
## rak (ruby) ack (perl)
$ rak v5ozp app
app/templates/example_form.html.tjn

25| <!-- [!v5ozp] -->
## file: example_form.html.tjn
24:
25: <!-- [!v5ozp] -->
26: <p>
27: <form>
28: Name: <input name="name">
29: Comment: <in...
function render() {
return (
<div data-eid="!1tscw">
<h3>TODO</h3>
<TodoList items={this.state.items} />
<form onSubmit={t...








なんでもID
なんでもID
なんでもID
なんでもID
なんでもID
なんでもID
なんでもID
なんでもID
なんでもID
なんでもID
なんでもID
なんでもID
なんでもID
なんでもID
なんでもID
なんでもID
Prochain SlideShare
Chargement dans…5
×

なんでもID

521 vues

Publié le

なんでもIDをつけましょう。そうすれば、コードの詳細を知らなくても、問題箇所が機械的に特定できます。

Publié dans : Technologie
  • Soyez le premier à commenter

  • Soyez le premier à aimer ceci

なんでもID

  1. 1. $ python tests/api_books_test.py * GET /api/2/books - [pass] returns list of books. - [Fail] accepts 'size' parameter. --------------------------------------------- [Fail] API_Test > GET /api/2/books
 > 002: accepts 'size' parameter. File "tests/api_books_test.py", line 268 ok (len(items)) == 20 AssertionError: 33 == 20 : failed. ---------------------------------------------
  2. 2. class BooksAPI_Test(TestCase): with subject("/api/v1/books"): @test("accepts 'size' parameter.") def _(self, api): qs = "size=20" resp = api.GET('/api/v1/books?'+qs) books = resp.json['books'] ok (len(books)) == 20
  3. 3. $ ls app/**/*.py | wc -l 123 $ ls app/api/**.py | wc -l 23 $ ls app/models/**.py | wc -l 45 $ ls app/usecases/**.py | wc -l 55
  4. 4. GET /api/v1/books class BooksAPI def do_list() class BooksService def find_books()
  5. 5. class BookService(Service): def find_books(self, **kwargs): q = db.query(Book) order = kwargs.pop('order') if order: q = q.order_by(order) limit = kwargs.pop('limit') if limit: q = q.limit(limit) if kwargs: q = q.filter_by(**kwargs) return q.all()
  6. 6. class BookService(Service): def find_books(self, **kwargs): q = db.query(Book) order = kwargs.pop('order') if order: q = q.order_by(order) #; [!mf7cw] accepts 'size' parameter. limit = kwargs.pop('limit') if limit: q = q.limit(limit) if kwargs: q = q.filter_by(**kwargs) return q.all()
  7. 7. class BooksAPI_Test(TestCase): with subject("/api/v1/books"): @test("[!mf7cw] accepts 'size' parameter.") def _(self, api): qs = "size=20" resp = api.GET('/api/v1/books?'+qs) books = resp.json['books'] ok (len(books)) == 20
  8. 8. $ python tests/api_books_test.py * GET /api/2/books - [pass] returns list of books. - [Fail] accepts 'size' parameter. --------------------------------------------- [Fail] API_Test > GET /api/2/books
 > 002: [!mf7cw] accepts 'size' parameter. File "tests/api_books_test.py", line 268 ok (len(items)) == 20 AssertionError: 33 == 20 : failed. ---------------------------------------------
  9. 9. ## -n: -r: $ grep -nr mf7cw app app/services/book_service.py:199: #; [!mf7cw] accepts 'size' parameter.
  10. 10. ## file: app/services/book_service.py 194: class BookService(Service): 195: def find_books(self, **kwargs): 196: q = db.query(Book) 197: order = kwargs.pop('order') 198: if order: q = q.order_by(order) 199: #; [!mf7cw] accepts 'size' parameter. 200: limit = kwargs.pop('limit') 201: if limit: q = q.limit(limit) 202: if kwargs: q = q.filter_by(**kwargs) 203: return q.all()
  11. 11. $ less /var/log/postgresql/pg9.3-main.log 2016-12-01 12:34:56 JST [46212] LOG: duration: 2671.751 ms statement: select * from books where title like '%SQL%' order by title limit 100 .....
  12. 12. $ ls app/**/*.py | wc -l 123 $ ls app/api/**.py | wc -l 23 $ ls app/models/**.py | wc -l 45 $ ls app/usecases/**.py | wc -l 55
  13. 13. sql = """ /* [sql:dolxq] */ select * from books where title like :pattern order by title limit :limit """ vars = {"title": "%SQL%", limit: 10} result = db.execute(sql, vars)
  14. 14. 2016-12-01 12:34:56 JST [46212] LOG: duration: 2671.751 ms statement: /* [sql:dolxq] */ select * from books where title like '%SQL%' order by title limit 100
  15. 15. ## grep ag (SilverSearcher) $ ag dolxq app app/services/book_service.py 79: /* [sql:dolxq] */
  16. 16. ## file: app/services/book_service.py 78: sql = """ 79: /* [sql:dolxq] */ 80: select * 81: from books 82: where title like :pattern 83: order by title 84: limit :limit 85: """ 86: vars = {"title": "%SQL%", limit: 10} 87: result = db.execute(sql, vars)
  17. 17. <p> <form> Name: <input name="name"> Comment: <input name="comment"> <input type="submit"> </form> </p>
  18. 18. $ ls app/**/*.html* | wc -l 302 $ ls app/**/*.py | wc -l 123
  19. 19. <!-- [!v5ozp] --> <p> <form> Name: <input name="name"> Comment: <input name="comment"> <input type="submit"> </form> </p>
  20. 20. <p data-eid="!v5ozp"> <form> Name: <input name="name"> Comment: <input name="comment"> <input type="submit"> </form> </p>
  21. 21. <!-- [!v5ozp] --> <p> <form> Name: <input name="name"> Comment: <input name="comment"> <input type="submit"> </form> </p>
  22. 22. ## rak (ruby) ack (perl) $ rak v5ozp app app/templates/example_form.html.tjn
 25| <!-- [!v5ozp] -->
  23. 23. ## file: example_form.html.tjn 24: 25: <!-- [!v5ozp] --> 26: <p> 27: <form> 28: Name: <input name="name"> 29: Comment: <input name="comment"> 30: <input type="submit"> 31: </form> 32: </p>
  24. 24. function render() { return ( <div data-eid="!1tscw"> <h3>TODO</h3> <TodoList items={this.state.items} /> <form onSubmit={this.handleSubmit}> <input value={this.state.text} /> <button>Add</button> </form> </div> ); }
  25. 25. 
 
 

  26. 26.

×