metaclass=ABCMeta): """ Tests for `GitLabBaseServiceController`. """ def test_start(self): service = self._start_service() response = requests.post( f"http://localhost:{service.ports[80]}/api/v3/session", data={ "login": service.root_user.username, "password": service.root_user.password }) print(response.text) response_payload = json.loads(response.text) self.assertEqual(service.root_user.username, response_payload["username"]) # Setup tests globals().update( create_tests( _TestGitLabBaseServiceController, get_classes_to_test(gitlab_service_controllers, GitLabServiceController))) # Fix for stupidity of test runners del _TestGitLabBaseServiceController, TestServiceControllerSubclass, create_tests, get_classes_to_test if __name__ == "__main__": unittest.main()
from testhelpers import TypeUsedInTest, create_tests, get_classes_to_test from useintest.tests.services.common import TestDockerisedServiceControllerSubclass class _TestBissellDockerisedServiceController( TestDockerisedServiceControllerSubclass[TypeUsedInTest, DockerisedServiceWithUsers], metaclass=ABCMeta): """ Tests for Mongo service controllers. """ def test_start(self): service = self._start_service() response = requests.head(f"http://{service.host}:{service.port}") self.assertEqual(401, response.status_code) # Setup tests CLASSES_TO_TEST = {LatestBissellDockerisedServiceController} globals().update( create_tests( _TestBissellDockerisedServiceController, get_classes_to_test(bissell_service_controllers, BissellServiceController))) # Fix for stupidity of test runners del _TestBissellDockerisedServiceController, TestDockerisedServiceControllerSubclass, create_tests, get_classes_to_test if __name__ == "__main__": unittest.main()
from useintest.tests.common import extract_version_number class _TestSetupIrods(TestUsingType[TypeUsedInTest], metaclass=ABCMeta): """ Tests for `setup_irods`. """ def test_setup(self): icommands_location, service, icommands_controller, icat_controller = setup_irods( self.get_type_to_test()) self.assertIsInstance(icommands_controller, IrodsBaseExecutablesController) self.assertIsInstance(icat_controller, self.get_type_to_test()) setup_helper = IrodsSetupHelper(icommands_location) self.assertEqual(service.version, setup_helper.get_icat_version()) # Setup tests globals().update( create_tests( _TestSetupIrods, get_classes_to_test(irods_service_controllers, IrodsServiceController), lambda superclass, test_type: "TestSetupWith%s" % extract_version_number(test_type.__name__).replace(".", "_"))) # Fix for stupidity of test runners del _TestSetupIrods, TestUsingType, create_tests, get_classes_to_test if __name__ == "__main__": unittest.main()
DockerisedServiceWithUsers], metaclass=ABCMeta): """ Tests for Mongo service controllers. """ def test_start(self): service = self._start_service() client = MongoClient(service.host, service.port) database = client["test-database"] posted = {"this": "value"} post_id = database.posts.insert_one(posted).inserted_id retrieved = database.posts.find_one({"_id": post_id}) self.assertEqual(retrieved, posted) # Setup tests CLASSES_TO_TEST = { Mongo3DockerisedServiceController, MongoLatestDockerisedServiceController } globals().update( create_tests( _TestMongoDockerisedServiceController, get_classes_to_test(mongo_service_controllers, MongoServiceController))) # Fix for stupidity of test runners del _TestMongoDockerisedServiceController, TestDockerisedServiceControllerSubclass, create_tests, get_classes_to_test if __name__ == "__main__": unittest.main()
class _TestCouchDBDockerisedServiceController( TestDockerisedServiceControllerSubclass[TypeUsedInTest, DockerisedServiceWithUsers], metaclass=ABCMeta): """ Tests for CouchDB service controllers. """ def test_start(self): service = self._start_service() couch = Server("http://%s:%d" % (service.host, service.port)) database = couch.create("test-database") posted = {"this": "value"} identifier, revision = database.save(posted) self.assertEqual(posted, database[identifier]) # Setup tests globals().update( create_tests( _TestCouchDBDockerisedServiceController, get_classes_to_test(couchdb_service_controllers, CouchDBServiceController))) # Fix for stupidity of test runners del _TestCouchDBDockerisedServiceController, TestDockerisedServiceControllerSubclass, create_tests, get_classes_to_test if __name__ == "__main__": unittest.main()
def test_setup_environment(self): service = self._start_service() # type: ConsulDockerisedService service.setup_environment() consul_client = Consul() self._test_client(consul_client) def _test_client(self, consul_client: Consul): """ Tests that the given Consul client connects to Consul :param consul_client: the Consul client to test """ consul_client.kv.put(_TEST_KEY, _TEST_VALUE) self.assertEqual( _TEST_VALUE, consul_client.kv.get(_TEST_KEY)[1]["Value"].decode("utf-8")) # Setup tests globals().update( create_tests( _TestConsulServiceController, get_classes_to_test(consul_service_controllers, ConsulServiceController))) # Fix for stupidity of test runners del _TestConsulServiceController, TestServiceControllerSubclass, create_tests, get_classes_to_test if __name__ == "__main__": unittest.main()
self.assertIn("%s#%s:read object" % (user_1.username, zone), access_info) self.assertIn("%s#%s:modify object" % (user_2.username, zone), access_info) def test_get_icat_version(self): self.assertEqual(self.service.version, self.setup_helper.get_icat_version()) def _assert_metadata_in_retrieved(self, metadata: Dict, retrieved_metadata: str): """ Assert that the given metadata is in the metadata information retrieved via an `imeta` command. :param metadata: the metadata to expect :param retrieved_metadata: string representation of metadata, retrieved via an `imeta` command """ for attribute in metadata: attribute_values = metadata[attribute] if not isinstance(attribute_values, list): attribute_values = [attribute_values] for value in attribute_values: self.assertIn("attribute: %s\nvalue: %s" % (attribute, value), retrieved_metadata) globals().update(create_tests(_TestIrodsSetupHelper, get_classes_to_test(irods_service_controllers, IrodsServiceController), lambda superclass, test_type: "TestIrodsSetupHelperWithIrods%s" % extract_version_number(test_type.__name__).replace(".", "_"))) # Fix for stupidity of test runners del _TestIrodsSetupHelper, TestServiceControllerSubclass, create_tests, get_classes_to_test if __name__ == "__main__": unittest.main()
metaclass=ABCMeta): """ Tests for `GogsBaseServiceController`. """ def test_start(self): service = self._start_service() authentication = UsernamePassword(service.root_user.username, service.root_user.password) gogs_connection = GogsApi( f"http://{service.host}:{service.ports[3000]}") gogs_connection.create_repo(authentication, _REPO_NAME) self.assertEqual( f"{authentication.username}/{_REPO_NAME}", gogs_connection.get_repo(authentication, authentication.username, _REPO_NAME).full_name) # Setup tests globals().update( create_tests( _TestGogsBaseServiceController, get_classes_to_test(gogs_service_controllers, GogsServiceController))) # Fix for stupidity of test runners del _TestGogsBaseServiceController, TestServiceControllerSubclass, create_tests, get_classes_to_test if __name__ == "__main__": unittest.main()