class TestResultPublisher(unittest.TestCase):
    def setUp(self):
        self.logger = logging.getLogger(__name__)

        # Load ledger base url from configuration
        parser = SafeConfigParser()
        parser.read('load.ini')
        baseUrl = parser.get('general', 'host')

        # Initialize ledger api client
        self.ledgerApi = LedgerApi(baseUrl)

        with open('tests/resources/fingerprint_template.json','r') as fingerprint_template_file:
            fingerprint_template = fingerprint_template_file.read()
        with open('tests/resources/vote_template.json','r') as vote_template_file:
            vote_template = vote_template_file.read()

        voteBase64 = b64encode(vote_template)

        self.testFingerprint = fingerprint_template % voteBase64

        self.username = faker.email()
        self.password = "******"
        self.journalId = self.setupJournal(self.username, self.password)

    def setupJournal(self, username, password):
        session = self.ledgerApi.createUser(username, password)

        journalId = self.ledgerApi.createJournal(session, faker.name())

        recordId = self.ledgerApi.createRecord(session)
        self.ledgerApi.saveRecordFingerprint(session, recordId, self.testFingerprint)
        self.ledgerApi.commitRecord(session, journalId, recordId)

        # Uncomment next line if need to timestamp (create a transaction in blockchain)
        self.ledgerApi.timestampJournal(session, journalId)

        return journalId

    def test_publish_results(self):
        publish_results(self.username, self.password, self.journalId)
        self.assertTrue(True)
Create user

"""

# TODO implement click
# import click
# @click.command()
# @click.option('--timestamp-weight', default=1, help='Weight of a timestamp operation')

logger.debug('Starting creating an user')

username = faker.email()
password = "******"

AL_AUTH = ledgerApi.createUser(username, password)

# save user info to config
parser.set('general', 'auth', AL_AUTH)
parser.set('general', 'username', username)
parser.set('general', 'password', password)

logger.debug('User created.')

"""

Create journal

"""

logger.debug('Starting creating a journal')