add cli tests and test paginated searching in search api test
continuous-integration/drone/pr Build is failing
Details
continuous-integration/drone/pr Build is failing
Details
This commit is contained in:
parent
dadd9bccca
commit
d3f23cf31d
|
@ -77,6 +77,46 @@ def test_groups(cli_setup, ldap_user):
|
||||||
result = runner.invoke(cli, ['groups', 'delete', 'test_group_1'], input='y\n')
|
result = runner.invoke(cli, ['groups', 'delete', 'test_group_1'], input='y\n')
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
|
|
||||||
|
group_names = [
|
||||||
|
"touch",
|
||||||
|
"error",
|
||||||
|
"happy",
|
||||||
|
"moon",
|
||||||
|
"decisive",
|
||||||
|
"exciting",
|
||||||
|
"super",
|
||||||
|
"ambitious",
|
||||||
|
"acidic",
|
||||||
|
"addition",
|
||||||
|
"blue-eyed",
|
||||||
|
"grate",
|
||||||
|
"replace",
|
||||||
|
"natural",
|
||||||
|
"explode",
|
||||||
|
"decorous",
|
||||||
|
"wide",
|
||||||
|
"hang",
|
||||||
|
"tomatoes",
|
||||||
|
"thirsty",
|
||||||
|
]
|
||||||
|
runner = CliRunner()
|
||||||
|
for name in group_names:
|
||||||
|
result = runner.invoke(cli, [
|
||||||
|
'groups', 'add', name, '-d', 'searchable group',
|
||||||
|
], input='y\n')
|
||||||
|
assert result.exit_code == 0
|
||||||
|
|
||||||
|
for name in group_names:
|
||||||
|
result = runner.invoke(cli, ['groups', 'search', '--count=1', name])
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert result.output.find(name) != -1
|
||||||
|
|
||||||
|
for name in group_names:
|
||||||
|
result = runner.invoke(cli, [
|
||||||
|
'groups', 'removemember', name, ldap_user.uid,
|
||||||
|
], input='y\n')
|
||||||
|
assert result.exit_code == 0
|
||||||
|
|
||||||
|
|
||||||
def create_group(group_name, desc):
|
def create_group(group_name, desc):
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|
|
@ -113,28 +113,158 @@ def test_api_add_member_to_group(client, create_group_result, ldap_user):
|
||||||
|
|
||||||
@pytest.fixture(scope='module')
|
@pytest.fixture(scope='module')
|
||||||
def create_random_names():
|
def create_random_names():
|
||||||
# 20 random names generated using this website: https://randomwordgenerator.com/
|
# 150 random names generated with https://www.randomlists.com/random-words
|
||||||
random_names = [
|
random_names = [
|
||||||
"inspiration",
|
"intelligent",
|
||||||
"at",
|
"skin",
|
||||||
"pneumonia",
|
"shivering",
|
||||||
"vision",
|
"hapless",
|
||||||
"infrastructure",
|
"abstracted",
|
||||||
"ceremony",
|
"kiss",
|
||||||
"plastic",
|
"decision",
|
||||||
"ambition",
|
"van",
|
||||||
"brain",
|
"advise",
|
||||||
"iron",
|
"parcel",
|
||||||
"world",
|
"disillusioned",
|
||||||
"overlook",
|
"print",
|
||||||
"pledge",
|
"skate",
|
||||||
"discreet",
|
"robin",
|
||||||
"glide",
|
"explode",
|
||||||
"brilliance",
|
"fearless",
|
||||||
"meet",
|
"feeling",
|
||||||
"hobby",
|
"chemical",
|
||||||
"applaud",
|
"identify",
|
||||||
"frighten",
|
"baseball",
|
||||||
|
"room",
|
||||||
|
"contain",
|
||||||
|
"smooth",
|
||||||
|
"play",
|
||||||
|
"fierce",
|
||||||
|
"north",
|
||||||
|
"secretive",
|
||||||
|
"plug",
|
||||||
|
"rely",
|
||||||
|
"home",
|
||||||
|
"push",
|
||||||
|
"guard",
|
||||||
|
"allow",
|
||||||
|
"depressed",
|
||||||
|
"evasive",
|
||||||
|
"slap",
|
||||||
|
"delicate",
|
||||||
|
"concern",
|
||||||
|
"consider",
|
||||||
|
"fang",
|
||||||
|
"roll",
|
||||||
|
"bait",
|
||||||
|
"rabbits",
|
||||||
|
"guarded",
|
||||||
|
"abnormal",
|
||||||
|
"loutish",
|
||||||
|
"voracious",
|
||||||
|
"chase",
|
||||||
|
"army",
|
||||||
|
"harsh",
|
||||||
|
"grieving",
|
||||||
|
"tacky",
|
||||||
|
"far",
|
||||||
|
"wise",
|
||||||
|
"street",
|
||||||
|
"price",
|
||||||
|
"bikes",
|
||||||
|
"post",
|
||||||
|
"afternoon",
|
||||||
|
"deranged",
|
||||||
|
"cart",
|
||||||
|
"evanescent",
|
||||||
|
"shrill",
|
||||||
|
"uppity",
|
||||||
|
"adhoc ",
|
||||||
|
"alleged",
|
||||||
|
"round",
|
||||||
|
"smart",
|
||||||
|
"support",
|
||||||
|
"plantation",
|
||||||
|
"flap",
|
||||||
|
"pretty",
|
||||||
|
"radiate",
|
||||||
|
"excite",
|
||||||
|
"memorize",
|
||||||
|
"whisper",
|
||||||
|
"thoughtless",
|
||||||
|
"substantial",
|
||||||
|
"upset",
|
||||||
|
"pathetic",
|
||||||
|
"flow",
|
||||||
|
"shake",
|
||||||
|
"wail",
|
||||||
|
"share",
|
||||||
|
"songs",
|
||||||
|
"scream",
|
||||||
|
"aspiring",
|
||||||
|
"overwrought",
|
||||||
|
"mass",
|
||||||
|
"romantic",
|
||||||
|
"deliver",
|
||||||
|
"anxious",
|
||||||
|
"laborer",
|
||||||
|
"angry",
|
||||||
|
"faded",
|
||||||
|
"wish",
|
||||||
|
"homeless",
|
||||||
|
"salty",
|
||||||
|
"start",
|
||||||
|
"crooked",
|
||||||
|
"tremble",
|
||||||
|
"enjoy",
|
||||||
|
"chivalrous",
|
||||||
|
"useless",
|
||||||
|
"womanly",
|
||||||
|
"brake",
|
||||||
|
"wandering",
|
||||||
|
"please",
|
||||||
|
"cow",
|
||||||
|
"reason",
|
||||||
|
"expert",
|
||||||
|
"null",
|
||||||
|
"basket",
|
||||||
|
"early",
|
||||||
|
"river",
|
||||||
|
"prevent",
|
||||||
|
"sticks",
|
||||||
|
"vacation",
|
||||||
|
"eggnog",
|
||||||
|
"receive",
|
||||||
|
"memory",
|
||||||
|
"exchange",
|
||||||
|
"burly",
|
||||||
|
"agreement",
|
||||||
|
"flock",
|
||||||
|
"subdued",
|
||||||
|
"clap",
|
||||||
|
"simplistic",
|
||||||
|
"tiger",
|
||||||
|
"responsible",
|
||||||
|
"knock",
|
||||||
|
"camera",
|
||||||
|
"nifty",
|
||||||
|
"capable",
|
||||||
|
"disappear",
|
||||||
|
"afterthought",
|
||||||
|
"obese",
|
||||||
|
"harass",
|
||||||
|
"delicious",
|
||||||
|
"badge",
|
||||||
|
"dam",
|
||||||
|
"plate",
|
||||||
|
"acrid",
|
||||||
|
"voiceless",
|
||||||
|
"mate",
|
||||||
|
"juice",
|
||||||
|
"food",
|
||||||
|
"town",
|
||||||
|
"giraffe",
|
||||||
|
"decorate"
|
||||||
]
|
]
|
||||||
yield random_names
|
yield random_names
|
||||||
|
|
||||||
|
@ -154,11 +284,26 @@ def create_searchable_groups(client, create_random_names):
|
||||||
|
|
||||||
def test_api_group_search(client, create_searchable_groups):
|
def test_api_group_search(client, create_searchable_groups):
|
||||||
cns = create_searchable_groups
|
cns = create_searchable_groups
|
||||||
for i, cn in enumerate(cns):
|
# pairs of cn indices as well as amount of results that should be returned
|
||||||
status, data = client.get(f'/api/groups/search/{cn}/{i + 1}')
|
random_numbers = [
|
||||||
|
(88, 68),
|
||||||
|
(117, 54),
|
||||||
|
(63, 97),
|
||||||
|
(64, 19),
|
||||||
|
(114, 98),
|
||||||
|
(45, 146),
|
||||||
|
(58, 12),
|
||||||
|
(42, 126),
|
||||||
|
(66, 137),
|
||||||
|
(39, 135),
|
||||||
|
]
|
||||||
|
|
||||||
|
for tup in random_numbers:
|
||||||
|
cn = cns[tup[0]]
|
||||||
|
status, data = client.get(f'/api/groups/search/{cn}/{tup[1]}')
|
||||||
assert status == 200
|
assert status == 200
|
||||||
assert data[0] == cn
|
assert data[0] == cn
|
||||||
assert len(data) == (i + 1)
|
assert len(data) == tup[1]
|
||||||
|
|
||||||
for cn in cns:
|
for cn in cns:
|
||||||
status, data = client.delete(f'/api/groups/{cn}')
|
status, data = client.delete(f'/api/groups/{cn}')
|
||||||
|
|
Loading…
Reference in New Issue