Exemple #1
0
 def test_get_credentials(self):
     # Prepare command
     sys.argv = [
         "pynuance",
         'credentials',
         '-C',
         self.cookies_file,
         '-c',
         self.credentials_file,
     ]
     # Run it
     main()
     # Check it
     assert os.path.isfile(self.credentials_file)
Exemple #2
0
 def test_mix_model_upload(self, capsys):
     # Test Mix account
     if not MIX_READY:
         pytest.skip("Mix account not ready")
     # prepare command
     sys.argv = [
         "pynuance", 'mix', '-C', self.cookies_file, 'model', '-m',
         self.model_name, 'upload', '-M', 'tests/upload.trsx'
     ]
     # run it
     main()
     out, err = capsys.readouterr()
     # check it
     assert out == ('''Sending: {}\nFile "{}" uploaded to model '''
                    '''"{}"\n'''.format(self.model_file, self.model_file,
                                        self.model_name))
Exemple #3
0
 def test_mix_model_list(self, capsys):
     # Test Mix account
     if not MIX_READY:
         pytest.skip("Mix account not ready")
     # Prepare command
     sys.argv = [
         "pynuance",
         'mix',
         '-C',
         self.cookies_file,
         'model',
         'list',
     ]
     # Run it
     main()
     out, err = capsys.readouterr()
     # Check it
     assert out.find(" | {}".format(self.model_name)) != -1
Exemple #4
0
 def test_mix_model_build_attach(self, capsys):
     # Test Mix account
     if not MIX_READY:
         pytest.skip("Mix account not ready")
     # prepare command
     sys.argv = [
         "pynuance", 'mix', '-C', self.cookies_file, 'model', '-m',
         self.model_name, 'build', 'attach', '-T', self.context_tag
     ]
     # run it
     main()
     out, err = capsys.readouterr()
     # check it
     assert out == (
         'The latest build of model "{}" is now attached to the "SandBox" App '
         'with context tag "{}"\n'.format(self.model_name,
                                          self.context_tag))
     # Wait for 5 sec for model build attachment
     time.sleep(5)
Exemple #5
0
 def test_mix_model_delete(self, capsys):
     # Test Mix account
     if not MIX_READY:
         pytest.skip("Mix account not ready")
     # Prepare command
     sys.argv = [
         "pynuance",
         'mix',
         '-C',
         self.cookies_file,
         'model',
         '-m',
         self.model_name,
         'delete',
     ]
     # Run it
     main()
     out, err = capsys.readouterr()
     # Check it
     assert out == """Model "{}" deleted\n""".format(self.model_name)
Exemple #6
0
 def test_mix_check(self, capsys):
     global MIX_READY
     # Prepare command
     sys.argv = [
         "pynuance",
         'mix',
         '-C',
         self.cookies_file,
         'check',
     ]
     # Run it
     main()
     out, err = capsys.readouterr()
     if out == "Your Mix account is activated, you can use NLU\n":
         # Mix ready
         assert True
         MIX_READY = True
     else:
         # Mix not ready
         assert out == "Your Mix account is being created or is not requested\n"
         MIX_READY = False
Exemple #7
0
 def test_mix_model_build_list(self, capsys):
     # Test Mix account
     if not MIX_READY:
         pytest.skip("Mix account not ready")
     # prepare command
     sys.argv = [
         "pynuance",
         'mix',
         '-C',
         self.cookies_file,
         'model',
         '-m',
         self.model_name,
         'build',
         'list',
     ]
     # run it
     main()
     out, err = capsys.readouterr()
     # check it
     assert out.find(" 1 | ") != -1
Exemple #8
0
 def test_mix_nlu_text(self, capsys):
     # Test Mix account
     if not MIX_READY:
         pytest.skip("Mix account not ready")
     # Prepare command
     sys.argv = [
         "pynuance",
         'nlu',
         '-c',
         self.credentials_file,
         '-l',
         'en_US',
         '-T',
         self.context_tag,
         'text',
         '-t',
         "What time is it ?",
     ]
     # Run it
     main()
     out, err = capsys.readouterr()
     # Check it
     assert out.find("get_time") != -1
Exemple #9
0
 def test_mix_model_train(self, capsys):
     # Test Mix account
     if not MIX_READY:
         pytest.skip("Mix account not ready")
     # prepare command
     sys.argv = [
         "pynuance",
         'mix',
         '-C',
         self.cookies_file,
         'model',
         '-m',
         self.model_name,
         'train',
     ]
     # run it
     main()
     out, err = capsys.readouterr()
     # check it
     assert out == ('''Training: {}\nModel "{}" trained\n'''.format(
         self.model_name, self.model_name))
     # Wait for 5 sec for model training
     time.sleep(5)
Exemple #10
0
 def test_mix_model_build_create(self, capsys):
     # Test Mix account
     if not MIX_READY:
         pytest.skip("Mix account not ready")
     # prepare command
     sys.argv = [
         "pynuance",
         'mix',
         '-C',
         self.cookies_file,
         'model',
         '-m',
         self.model_name,
         'build',
         'create',
     ]
     # run it
     main()
     out, err = capsys.readouterr()
     # check it
     assert out == ('New build created for model "{}"\n'.format(
         self.model_name))
     # Wait for 5 sec for model build creation
     time.sleep(5)