Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Test serializing a ticket with missing/empty description.

  • Loading branch information...
commit f4d0049aef7061f4a866db8b2f5472a108411bc5 1 parent c555314
Tv authored

Showing 2 changed files with 89 additions and 4 deletions. Show diff stats Hide diff stats

  1. +6 4 bugit/serialize.py
  2. +83 0 bugit/test/test_cmd_show.py
10 bugit/serialize.py
@@ -51,10 +51,12 @@ def serialize(
51 51 break_long_words=False,
52 52 )
53 53 print >>fp
54   - description = snapshot.get(os.path.join(ticket, 'description')).rstrip()
55   - if description:
56   - print >>fp, description
57   - print >>fp
  54 + description = snapshot.get(os.path.join(ticket, 'description'))
  55 + if description is not None:
  56 + description = description.rstrip()
  57 + if description:
  58 + print >>fp, description
  59 + print >>fp
58 60 print >>fp, '--'
59 61 def get_the_rest():
60 62 for name in snapshot.ls(ticket):
83 bugit/test/test_cmd_show.py
@@ -513,3 +513,86 @@ def test_multiple():
513 513
514 514 --
515 515 """)
  516 +
  517 +def test_description_missing():
  518 + # not really sure how you could end up without a description, but
  519 + # let's not totally fail
  520 + tmp = util.maketemp()
  521 + storage.git_init(tmp)
  522 + storage.init(tmp)
  523 + with storage.Transaction(repo=tmp) as t:
  524 + t.set(
  525 + 'd239371f3b6b61ca1076bb460e331b3edb412970/number',
  526 + '3431\n',
  527 + )
  528 + result = util.clitest(
  529 + args=[
  530 + 'show',
  531 + 'd239',
  532 + ],
  533 + cwd=tmp,
  534 + )
  535 + result.check_stdout("""\
  536 +ticket d239371f3b6b61ca1076bb460e331b3edb412970
  537 +number #3431
  538 +
  539 +--
  540 +""")
  541 +
  542 +def test_description_empty():
  543 + # not really sure how you could end up without a description, but
  544 + # let's not totally fail
  545 + tmp = util.maketemp()
  546 + storage.git_init(tmp)
  547 + storage.init(tmp)
  548 + with storage.Transaction(repo=tmp) as t:
  549 + t.set(
  550 + 'd239371f3b6b61ca1076bb460e331b3edb412970/description',
  551 + '',
  552 + )
  553 + t.set(
  554 + 'd239371f3b6b61ca1076bb460e331b3edb412970/number',
  555 + '3431\n',
  556 + )
  557 + result = util.clitest(
  558 + args=[
  559 + 'show',
  560 + 'd239',
  561 + ],
  562 + cwd=tmp,
  563 + )
  564 + result.check_stdout("""\
  565 +ticket d239371f3b6b61ca1076bb460e331b3edb412970
  566 +number #3431
  567 +
  568 +--
  569 +""")
  570 +
  571 +def test_description_whitespace():
  572 + # not really sure how you could end up without a description, but
  573 + # let's not totally fail
  574 + tmp = util.maketemp()
  575 + storage.git_init(tmp)
  576 + storage.init(tmp)
  577 + with storage.Transaction(repo=tmp) as t:
  578 + t.set(
  579 + 'd239371f3b6b61ca1076bb460e331b3edb412970/description',
  580 + '\n',
  581 + )
  582 + t.set(
  583 + 'd239371f3b6b61ca1076bb460e331b3edb412970/number',
  584 + '3431\n',
  585 + )
  586 + result = util.clitest(
  587 + args=[
  588 + 'show',
  589 + 'd239',
  590 + ],
  591 + cwd=tmp,
  592 + )
  593 + result.check_stdout("""\
  594 +ticket d239371f3b6b61ca1076bb460e331b3edb412970
  595 +number #3431
  596 +
  597 +--
  598 +""")

0 comments on commit f4d0049

Please sign in to comment.
Something went wrong with that request. Please try again.