|
| 1 | +#!/usr/bin/env python3 |
| 2 | +"""tests for article.py""" |
| 3 | + |
| 4 | +import os |
| 5 | +import random |
| 6 | +import re |
| 7 | +import string |
| 8 | +from subprocess import getstatusoutput |
| 9 | + |
| 10 | +prg = './article.py' |
| 11 | + |
| 12 | + |
| 13 | +# -------------------------------------------------- |
| 14 | +def test_exists(): |
| 15 | + """exists""" |
| 16 | + |
| 17 | + assert os.path.isfile(prg) |
| 18 | + |
| 19 | + |
| 20 | +# -------------------------------------------------- |
| 21 | +def test_usage(): |
| 22 | + """usage""" |
| 23 | + |
| 24 | + for flag in ['-h', '--help']: |
| 25 | + rv, out = getstatusoutput(f'{prg} {flag}') |
| 26 | + assert rv == 0 |
| 27 | + assert out.lower().startswith('usage') |
| 28 | + |
| 29 | + |
| 30 | +# -------------------------------------------------- |
| 31 | +def test_masculine_lower(): |
| 32 | + """masculine_lower""" |
| 33 | + |
| 34 | + word = random.choice('chico teatro cartero'.split()) |
| 35 | + rv, out = getstatusoutput(f'{prg} {word}') |
| 36 | + assert rv == 0 |
| 37 | + assert out == f'Me gusto el {word}.' |
| 38 | + |
| 39 | + |
| 40 | +# -------------------------------------------------- |
| 41 | +def test_masculine_upper(): |
| 42 | + """masculine_upper""" |
| 43 | + |
| 44 | + word = random.choice('CHICO TEATRO CARTERO'.split()) |
| 45 | + rv, out = getstatusoutput(f'{prg} {word}') |
| 46 | + assert rv == 0 |
| 47 | + assert out == f'Me gusto el {word}.' |
| 48 | + |
| 49 | + |
| 50 | +# -------------------------------------------------- |
| 51 | +def test_feminine_lower(): |
| 52 | + """feminine_lower""" |
| 53 | + |
| 54 | + word = random.choice('chica gata abuela'.split()) |
| 55 | + rv, out = getstatusoutput(f'{prg} {word}') |
| 56 | + assert rv == 0 |
| 57 | + assert out == f'Me gusto la {word}.' |
| 58 | + |
| 59 | + |
| 60 | +# -------------------------------------------------- |
| 61 | +def test_feminine_upper(): |
| 62 | + """feminine_upper""" |
| 63 | + |
| 64 | + word = random.choice('CHICA GATA ABUELA'.split()) |
| 65 | + rv, out = getstatusoutput(f'{prg} {word}') |
| 66 | + assert rv == 0 |
| 67 | + assert out == f'Me gusto la {word}.' |
0 commit comments