Some checks failed
Mark stable commit / test-unit (push) Has been cancelled
Mark stable commit / test-integration (push) Has been cancelled
Mark stable commit / test-env-virtual (push) Has been cancelled
Mark stable commit / test-env-nix (push) Has been cancelled
Mark stable commit / test-e2e (push) Has been cancelled
Mark stable commit / test-virgin-user (push) Has been cancelled
Mark stable commit / test-virgin-root (push) Has been cancelled
Mark stable commit / lint-shell (push) Has been cancelled
Mark stable commit / lint-python (push) Has been cancelled
Mark stable commit / mark-stable (push) Has been cancelled
21 lines
679 B
Python
21 lines
679 B
Python
from __future__ import annotations
|
|
|
|
import json
|
|
import unittest
|
|
|
|
from pkgmgr.actions.install.installers.nix.profile.parser import parse_profile_list_json
|
|
|
|
|
|
class TestParseProfileListJson(unittest.TestCase):
|
|
def test_parses_valid_json(self) -> None:
|
|
payload = {"elements": {"0": {"name": "pkgmgr"}}}
|
|
raw = json.dumps(payload)
|
|
self.assertEqual(
|
|
parse_profile_list_json(raw)["elements"]["0"]["name"], "pkgmgr"
|
|
)
|
|
|
|
def test_raises_systemexit_on_invalid_json(self) -> None:
|
|
with self.assertRaises(SystemExit) as cm:
|
|
parse_profile_list_json("{not json")
|
|
self.assertIn("Failed to parse", str(cm.exception))
|