import unittest import xml.etree.ElementTree as ET from lib.db import DB from lib.db_revision import DBRevision from lib.obs import OBS from lib.obs_revision import OBSRevision # needs to exist in local oscrc (little tricky) API_URL = "https://api.opensuse.org" class TestDBMethods(unittest.TestCase): def setUp(self): self.db = DB(section="test") self.obs = OBS(API_URL) def test_import(self): test_rev = OBSRevision(self.obs, "openSUSE:Factory", "xz") test_rev.parse( ET.fromstring( """ 37a33785d29ac57cdd5f2cbd7b0d6588 5.2.7 RBrownFactory 1008136 """ ) ) DBRevision.import_obs_rev(self.db, test_rev) db_rev = DBRevision.fetch_revision( self.db, project="openSUSE:Factory", package="xz", rev="70" ) self.assertEqual(db_rev.api_url, API_URL) self.assertEqual(str(test_rev), str(db_rev)) if __name__ == "__main__": unittest.main()