Compare commits

..

2 Commits

2 changed files with 44 additions and 2 deletions

View File

@@ -0,0 +1,33 @@
on:
push:
branches:
- main
jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run tests
run: |
./tests.py
# AI: generated... check validity
# - name: Upload test results
# if: always()
# uses: actions/upload-artifact@v2
# with:
# name: test-results
# path: tests/test_results.xml

View File

@@ -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__":