def setUp(self):
        Configs.config.override({
            "host": os.getenv('SERVER_HOST'),
            "port": os.getenv('PORT_NUMBER'),
            "db": os.getenv('DB_VALUE')
        })

        self.client = app.test_client
        self.hash_one = 'in'
        self.key = 'foo'
        self.value = 'bar'
        self.test_redis_methods = Readers.redis_methods()
        self.test_redis_methods.set_hash(self.hash_one, self.key, self.value)
Example #2
0
def main():
    parser = configparser.ConfigParser()
    if not parser.read('config.ini'):
        raise Exception('Failed to read config.ini')
    Configs.config.override({
        'domain_name': parser.get('email', 'domain_name'),
        'email_address': parser.get('email', 'email_address'),
        'password': parser.get('email', 'password'),
        'mailbox': parser.get('email', 'mailbox')
    })

    email_reader = Readers.email_reader()
    print(email_reader.read('(SUBJECT TestSubject)'))
Example #3
0
 def setUp(self):
     Configs.config.override({
         "host": os.getenv('SERVER_HOST'),
         "port": os.getenv('PORT_NUMBER'),
         "db": os.getenv('DB_VALUE')
     })
     self.test_redis_methods = Readers.redis_methods()
     self.hash_name = 'er'
     self.key = 'foo'
     self.value = 'bar'
     self.test_redis_methods.set_hash(self.hash_name, self.key, self.value)
     self.mock_client = Mock()
     self.mock_client.set_hash.return_value = '1'
     self.mock_client.get_hash.return_value = "b'bar'"
     self.mock_client.get_hash_dict.return_value = "b'bar'"
     self.mock_client.hash_check.return_value = True
     self.mock_client.delete_hash.return_value = 1
     self.hash_methods = RedisHashMethods(self.mock_client)
from containers import Readers, Clients, Configs
if __name__ == "__main__":
    Configs.config.override({
        "domain_name": "imap.gmail.com",
        "email_address": "YOUR_EMAIL_ADDRESS",
        "password": "******",
        "mailbox": "INBOX"
    })
    email_reader = Readers.email_reader()
    print email_reader.read('(SUBJECT TestSubject)')
Example #5
0
from flask import Flask, make_response, jsonify
import os

from containers import Configs, Readers, Clients

app = Flask(__name__)

Configs.config.override({
    "host": os.getenv('SERVER_HOST'),
    "port": os.getenv('PORT_NUMBER'),
    "db": os.getenv('DB_VALUE')
})

redis_methods = Readers.redis_methods()


@app.route('/api/v1.0/methods/<string:hash_name>/<string:key>/<string:value>',
           methods=['POST'])
def redis_set_hash(hash_name, key, value):
    """Set a hash value to a key value pair equivalent to Redis hset()"""
    output = redis_methods.set_hash(hash_name, key, value)

    if output:
        return make_response(jsonify({'Created': output}), 201)
    return make_response(jsonify({'Already Exists!': output}), 200)


@app.route('/api/v1.0/methods/<string:hash_name>/<string:key>',
           methods=['GET'])
def redis_get_hash(hash_name, key):
    """Gets the value of the key within the hash name