#!/usr/bin/env python3 """Tests for fetch_eks_conditions.py, on a page in the Service Authorization Reference's markup.""" from __future__ import annotations import pytest import fetch_eks_conditions as f SERVICE = " the user makes to the EKS service" def row(key: str, description: str) -> str: return f'{key}{description}String' ROWS = (row("eks:principalArn", "Filters access by the principalArn present in the access entry requests requests" + SERVICE) + row("eks:accessEntryType", "Filters access by the access entry type present in the access entry requests" + SERVICE) + row("eks:namespaces", "Filters access by the namespaces present in the associate / disassociate access " "policy requests" + SERVICE) + row("eks:authenticationMode", "Filters access by the authenticationMode present in the create / update " "cluster request")) def page(rows: str = ROWS) -> str: return f"{rows}
Condition keysDescriptionType
" def test_each_access_entry_key_is_read_from_the_member_its_row_names(): keys = {entry["key"]: entry for entry in f.build(lambda url: page())["keys"]} assert keys["eks:principalArn"]["member"] == "principalArn" # A member named in words is the one those words name. assert keys["eks:accessEntryType"]["member"] == "type" assert keys["eks:namespaces"]["requests"] == "associate / disassociate access policy requests" # A key of another request is not read here. assert "eks:authenticationMode" not in keys assert keys["eks:principalArn"]["row"].endswith("requests requests the user makes to the EKS service") def test_a_page_whose_layout_changed_is_refused(): with pytest.raises(ValueError, match="no table"): f.build(lambda url: "
") with pytest.raises(ValueError, match="no member's name"): f.build(lambda url: page(row("eks:principalArn", "Filters access by the principal ARN of the entry present " "in the access entry requests" + SERVICE))) def test_the_file_is_stale_when_the_page_says_something_else(): vendored = f.build(lambda url: page()) assert not f.stale(vendored, page()) assert f.stale(vendored, page(ROWS.replace("the principalArn present", "the principal present")))