Beispiel #1
0
def do_list(args):
    """
    list transactions of code smell family

    Args:
        args (array) arguments
    """
    if args.type is not None and args.type not in ('code_smell', 'proposal', 'vote'):
        raise CodeSmellException("Incorrect Transaction Type")
    if args.type in ('code_smell', 'vote') and args.active is not None:
        raise CodeSmellException("Incorrect parms combination")

    url = _get_url(args)
    keyfile = _get_keyfile(args)
    client = CodeSmellClient(base_url=url, keyfile=keyfile, work_path=HOME)

    if args.active is not None:
        transactions = client.list(txn_type=args.type, active_flag=1)
    else:
        transactions = client.list(txn_type=args.type)

    if len(transactions) == 0:
        raise CodeSmellException("No transactions found")
    else:
        print (transactions)
Beispiel #2
0
class SimpleTest(unittest.TestCase):
    def setUp(self):
        #get default values
        DISTRIBUTION_NAME = 'suserum-code_smell'
        HOME = os.getenv('SAWTOOTH_HOME')
        DEFAULT_URL = 'http://127.0.0.1:8008'

        #get user key
        username = getpass.getuser()
        home = os.path.expanduser("~")
        key_dir = os.path.join(home, ".sawtooth", "keys")
        keyfile = '{}/{}.priv'.format(key_dir, username)

        self.client = CodeSmellClient(base_url=DEFAULT_URL,
                                      keyfile=keyfile,
                                      work_path=HOME)

        #get test txn_id
        self.txn = self.client.list()
        for entry in self.txn.keys():
            self.txn_id = entry
            break

    def test_load_default(self):
        response = self.client.default()
        self.assertNotEqual(response, None)

    def test_default_repo_id(self):
        response = self.client.default(12345)
        self.assertNotEqual(response, None)

    def test_list(self):
        response = self.client.list()
        self.assertNotEqual(response, None)

    def test_list_incorrect_type(self):
        response = self.client.list("noType")
        self.assertEqual(len(response), 0)

    def test_bad_vote(self):
        self.assertRaises(CodeSmellException, self.client.vote, "234", "yes")

    def test_show_txn(self):
        response = self.client.show(self.txn_id)
        self.assertNotEqual(response, None)

    def test_incorrect_proposal_update(self):
        self.assertRaises(CodeSmellException, self.client._update_suse_file,
                          "LargeClass=kx,Smal")
Beispiel #3
0
def do_list(args):
    """
    list transactions of code smell family

    Args:
        args (array) arguments
    """
    #verify that we shave the right type
    if args.type is not None and args.type not in ('code_smell', 'proposal', 'vote', 'config'):
        raise CodeSmellException("Incorrect Transaction Type")

    url = _get_url(args)
    keyfile = _get_keyfile(args)
    client = CodeSmellClient(base_url=url, keyfile=keyfile, work_path=HOME)

    transactions = client.list(txn_type=args.type, active=args.active)

    if len(transactions) == 0:
        raise CodeSmellException("No transactions found")
    else:
        print (transactions)