Added missing item and children listing tests.
This commit is contained in:
13
tests.py
13
tests.py
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
import unittest
|
||||
import requests
|
||||
from azure.identity import DefaultAzureCredential
|
||||
from devops import DEVOPS_SCOPE, Organization, Repository, Project, Item
|
||||
|
||||
@@ -108,10 +109,18 @@ class Test04(unittest.TestCase):
|
||||
self.assertIsNotNone(item.commit_id)
|
||||
|
||||
def test_02(self):
|
||||
"""Trying to instantiate Item for a item that does not exist"""
|
||||
repo = Repository(Project(self.org, id="bafe0cf1-6c97-4088-864a-ea6dc02b2727"), id="feac266f-84d2-41bc-839b-736925a85eaa")
|
||||
with self.assertRaises(requests.exceptions.HTTPError):
|
||||
item = Item(repo, path="/non-existent-file.txt")
|
||||
self.assertEqual(item.path, "/non-existent-file.txt")
|
||||
commit_id = item.commit_id # This will raise HTTPError when trying to fetch details of a non-existent item
|
||||
|
||||
def test_03(self):
|
||||
"""Listing items in a folder within a repository"""
|
||||
repo = Repository(Project(self.org, id="bafe0cf1-6c97-4088-864a-ea6dc02b2727"), id="feac266f-84d2-41bc-839b-736925a85eaa")
|
||||
docs_item = Item(repo, path="/container")
|
||||
children = list(docs_item.children)
|
||||
item = Item(repo, path="/container")
|
||||
children = list(item.children)
|
||||
self.assertGreater(len(children), 0)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user