Esempio n. 1
0
def main(
    app_url: str,
    user: str,
    password: str,
    paths: Tuple[Path, ...],
    load_mode: str,
    mode: str,
    no_installed_keywords: bool,
) -> None:
    """Package to populate rfhub2 with robot framework keywords
       from libraries and resource files."""
    client = Client(app_url, user, password)
    if mode == "keywords":
        rfhub_importer = KeywordsImporter(client, paths, no_installed_keywords,
                                          load_mode)
        loaded_collections, loaded_keywords = rfhub_importer.import_data()
        print(
            f"\nSuccessfully loaded {loaded_collections} collections with {loaded_keywords} keywords."
        )
    elif mode == "statistics":
        rfhub_importer = StatisticsImporter(client, paths)
        loaded_files, loaded_statistics = rfhub_importer.import_data()
        print(
            f"\nSuccessfully loaded {loaded_files} files with {loaded_statistics} statistics."
        )
Esempio n. 2
0
 def test_import_data(self):
     with responses.RequestsMock() as rsps:
         rfhub_importer = KeywordsImporter(
             self.client,
             (self.fixture_path / "LibWithInit", ),
             True,
             load_mode="insert",
         )
         rsps.add(
             responses.GET,
             f"{self.client.api_url}/collections/",
             json=[],
             status=200,
             adding_headers={"Content-Type": "application/json"},
         )
         rsps.add(
             responses.POST,
             f"{self.client.api_url}/collections/",
             json={
                 "name": "LibWithInit",
                 "id": 2
             },
             status=201,
             adding_headers={
                 "Content-Type": "application/json",
                 "accept": "application/json",
             },
         )
         rsps.add(
             responses.POST,
             f"{self.client.api_url}/keywords/",
             json=KEYWORDS_2,
             status=201,
             adding_headers={
                 "Content-Type": "application/json",
                 "accept": "application/json",
             },
         )
         result = rfhub_importer.import_data()
         self.assertCountEqual(result, (1, 4), msg=f"{result}")