def filter_hours_ctx(
        name=DEFAULT_FILTER_DETAILS.filter_name,
        hours=DEFAULT_FILTER_DETAILS.hours_menu.hours_field,
        description=DEFAULT_FILTER_DETAILS.filter_description,
        organizations=DEFAULT_FILTER_DETAILS.organizations_field.select,
        subscription_states=DEFAULT_FILTER_DETAILS.status_field.select,
        lifecycle_states=DEFAULT_FILTER_DETAILS.lifecycle_field.select
    ):
    '''create a date-range-filter, yield it as a selected filter_menu, destroy it'''
    details = namespace.load_ns({
        'filter_name': name,
        'filter_description': description,
        'hours_menu': {
            'hours_field': hours,
        },
        'organizations_field': {
            'select': organizations
        },
        'status_field': {
            'select': subscription_states
        },
        'lifecycle_field': {
            'select': lifecycle_states
        }
    })
    with filter_details_ctx(details) as ctx:
        yield ctx
Exemplo n.º 2
0
 def fetch(self):
     '''shortcut for namespace.load_ns(json.loads(self.receiver.fetch().content))'''
     ret = self.receiver.fetch(timeout=self._timeout)
     self.session.acknowledge()
     self.last_fetched = ret
     if self._asserting:
         assert self.is_ok, 'Qpid session was not OK:\n%s' % self
     return namespace.load_ns(json.loads(ret.content))
Exemplo n.º 3
0
 def fetch(self):
     '''shortcut for namespace.load_ns(json.loads(self.receiver.fetch().content))'''
     ret = self.receiver.fetch(timeout=self._timeout)
     self.session.acknowledge()
     self.last_fetched = ret
     if self._asserting:
         assert self.is_ok, 'Qpid session was not OK:\n%s' % self
     return namespace.load_ns(json.loads(ret.content))
Exemplo n.º 4
0
 def message(self):
     '''shortcut for self.fetch() with some check-sums handling'''
     content = self.fetch()
     assert 'signature' in content, 'no signature in message: %s' % content
     try:
         signature = b64decode(content.signature)
     except TypeError as e:
         # rethrow as assertion failure
         raise AssertionError(e)
     self.auth.verify(content.message, signature)
     # The second load of message is required because
     # if the message was transported as a dict
     # the checksum/signature might change upon the message
     # deserialization (un-ordered-dict)??
     return namespace.load_ns(json.loads(content.message))
Exemplo n.º 5
0
 def message(self):
     '''shortcut for self.fetch() with some check-sums handling'''
     content = self.fetch()
     assert 'signature' in content, 'no signature in message: %s' % content
     try:
         signature = b64decode(content.signature)
     except TypeError as e:
         # rethrow as assertion failure
         raise AssertionError(e)
     self.auth.verify(content.message, signature)
     # The second load of message is required because
     # if the message was transported as a dict
     # the checksum/signature might change upon the message
     # deserialization (un-ordered-dict)??
     return namespace.load_ns(json.loads(content.message))
def filter_hours_ctx(
    name=DEFAULT_FILTER_DETAILS.filter_name,
    hours=DEFAULT_FILTER_DETAILS.hours_menu.hours_field,
    description=DEFAULT_FILTER_DETAILS.filter_description,
    organizations=DEFAULT_FILTER_DETAILS.organizations_field.select,
    subscription_states=DEFAULT_FILTER_DETAILS.status_field.select,
    lifecycle_states=DEFAULT_FILTER_DETAILS.lifecycle_field.select,
):
    """create a date-range-filter, yield it as a selected filter_menu, destroy it"""
    details = namespace.load_ns(
        {
            "filter_name": name,
            "filter_description": description,
            "hours_menu": {"hours_field": hours},
            "organizations_field": {"select": organizations},
            "status_field": {"select": subscription_states},
            "lifecycle_field": {"select": lifecycle_states},
        }
    )
    with filter_details_ctx(details) as ctx:
        yield ctx
    default_filter_menu = DefaultFilterMenu()

    def get_filter(self, filter_name):
        return FilterMenu(filter_name)

DEFAULT_FILTER_DETAILS=namespace.load_ns({
    'filter_name': u'A Filter',
    'filter_description': u'Some description string',
    'date_range_menu':{
        'start_date': u'01/01/1970',
        'end_date': u'01/01/1970',
    },
    # NOTE this will switch date_range_menu to hours_menu when used
    'hours_menu': {
        'hours_field': u"24"
    },
    'status_field': {
        'select': [u"Current", u"Insufficient", u"Invalid"]
    },
    'organizations_field': {
        'select': [u"ACME_Corporation"]
    },
    'lifecycle_field': {
        'select': [u"Active", u"Inactive", u"Deleted"]
    }
})


def create_filter(details=DEFAULT_FILTER_DETAILS):
    with restore_url():
        filters_page = Filters()
Exemplo n.º 8
0
 def data(self, _data):
     self.assert_data(_data)
     self._data = namespace.load_ns(_data)
Exemplo n.º 9
0
 def __init__(self, module, PROFILE=namespace.load_ns({}), catching=False):
     self.module = module
     self._catching = catching
     self.log = logging.getLogger(__name__ + "." + type(self).__name__)
     self.PROFILE = PROFILE
Exemplo n.º 10
0
# Page Objects
from selenium_wrapper import SE
from namespace import load_ns
from locator_assembler import locator_assembler
from pkg_resources import resource_filename
import yaml

LOCATORS_FILE="data/locators.yml"
PAGES_FILE="data/pages.yml"

# load&assemble the locators
with open(resource_filename(__name__, LOCATORS_FILE)) as fd:
    locators = load_ns(yaml.load(fd), leaf_processor=lambda x: locator_assembler(x[0], x[1]))

# load the pages
with open(resource_filename(__name__, PAGES_FILE)) as fd:
    pages = load_ns(yaml.load(fd))

Exemplo n.º 11
0
class Filters(SamPageObject):
    _sub_url = pages.filters.url
    new_filter_menu = NewFilterMenu()
    default_filter_menu = DefaultFilterMenu()

    def get_filter(self, filter_name):
        return FilterMenu(filter_name)


DEFAULT_FILTER_DETAILS = namespace.load_ns(
    {
        "filter_name": u"A Filter",
        "filter_description": u"Some description string",
        "date_range_menu": {"start_date": u"01/01/1970", "end_date": u"01/01/1970"},
        # NOTE this will switch date_range_menu to hours_menu when used
        "hours_menu": {"hours_field": u"24"},
        "status_field": {"select": [u"Current", u"Insufficient", u"Invalid"]},
        "organizations_field": {"select": [u"ACME_Corporation"]},
        "lifecycle_field": {"select": [u"Active", u"Inactive", u"Deleted"]},
    }
)


def create_filter(details=DEFAULT_FILTER_DETAILS):
    with restore_url():
        filters_page = Filters()
        namespace.setattr_ns(filters_page.new_filter_menu, details)
        filters_page.new_filter_menu.submit()
    return filters_page, filters_page.get_filter(details.filter_name)

Exemplo n.º 12
0
 def data(self, _data):
     self.assert_data(_data)
     self._data = namespace.load_ns(_data)
Exemplo n.º 13
0
# Page Objects
from selenium_wrapper import SE
from namespace import load_ns
from locator_assembler import locator_assembler
from pkg_resources import resource_filename
import yaml

LOCATORS_FILE = "data/locators.yml"
PAGES_FILE = "data/pages.yml"

# load&assemble the locators
with open(resource_filename(__name__, LOCATORS_FILE)) as fd:
    locators = load_ns(yaml.load(fd),
                       leaf_processor=lambda x: locator_assembler(x[0], x[1]))

# load the pages
with open(resource_filename(__name__, PAGES_FILE)) as fd:
    pages = load_ns(yaml.load(fd))
Exemplo n.º 14
0
 def __init__(self, module, PROFILE=namespace.load_ns({}), catching=False):
     self.module = module
     self._catching = catching
     self.log = logging.getLogger(__name__ + "." + type(self).__name__)
     self.PROFILE = PROFILE